how to do a cleaup action in useEffect when we use if in useEffect code example
Example 1: react use effect
useEffect(() => {
},[]);
Example 2: componentwillunmount hooks
useEffect(() => {
window.addEventListener('mousemove', () => {});
// returned function will be called on component unmount
return () => {
window.removeEventListener('mousemove', () => {})
}
}, [])