How to perform ComponentDidMount, ComponentDidUpadte and ComponentUnmount in functional component


In React functional components, you can achieve the equivalent behavior of componentDidMount, componentDidUpdate, and componentWillUnmount lifecycle methods using the useEffect hook.

1 componentDidMount

useEffect(() => {


2 componentDidUpdate

useEffect(() => {


3 componentWillUnmount

useEffect(() => { return()=>{ console.log(“Mount”)





Vineet Mishra

Full Stack Developer at CCR Tech, I write about Mobile/Web Development and Deployment, and Interview Q & A