Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

is useeffect called in component unmount

// cleanup function in use effect
useEffect( () => () => console.log("unmount"), [] );
// end
/*
	Notice :  the an arrow function inside Main arrow function is triggering component 
    unmount.
*/

useEffect( () => console.log("mount"), [] );
useEffect( () => console.log("will update data1"), [ data1 ] );
useEffect( () => console.log("will update any") );
useEffect( () => () => console.log("will update data1 or unmount"), [ data1 ] );
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #useeffect #called #component #unmount
ADD COMMENT
Topic
Name
9+7 =