stop dismount react useeffect code example
Example 1: useeffect umnount
useEffect(() => {
return () => {
console.log("cleaned up");
};
}, []);
Example 2: useeffect on update
const isInitialMount = useRef(true);
useEffect(() => {
if (isInitialMount.current) {
isInitialMount.current = false;
} else {
// Your useEffect code here to be run on update
}
});