useeffect for componentwillreceiveprops dependecy list code example

Example 1: componentwillunmount hooks

useEffect(() => {
  window.addEventListener('mousemove', () => {});

  // returned function will be called on component unmount 
  return () => {
    window.removeEventListener('mousemove', () => {})
  }
}, [])

Example 2: componentwillreceiveprops hooks

SomeComponent (props) => {

    useEffect( () => {
        console.log('someProp updated');
    }, [props.someProp])


    return <div>Hi {props.someProp}</div>
}