react hook version of componentdidupdate code example
Example 1: useeffect react
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
}, []);