component unmount in hooks code example
Example 1: componentwillunmount hooks
useEffect(() => {
window.addEventListener('mousemove', () => {});
// returned function will be called on component unmount
return () => {
window.removeEventListener('mousemove', () => {})
}
}, [])
Example 2: componentdidmount in hooks
useEffect(() => {
// Your code here
}, []);