DEV Community

Dhananjay Sahay
Dhananjay Sahay

Posted on

Component will unmount for functional components

I just learnt that if we have unmount functions being returned from useEffect like below, both the methods will be called on unmount. Not sure though if it's correct behavior or it's a bug in React. What could be the possible reason for keeping such behavior?
useEffect(() => {
return () => {
console.log('Unmount From DidMount');
};
}, []);

useEffect(() => {
return () => {
console.log('Unmount From will update');
};
}, [props.xyz]);

Top comments (0)