react useeffect effect specific code example
Example 1: react run useeffect only once
useEffect(() => {
// Initialization code comes here
}, []);
Example 2: useeffect react
useEffect(() => {
window.addEventListener('mousemove', () => {});
// returned function will be called on component unmount
return () => {
window.removeEventListener('mousemove', () => {})
}
}, [])