How to use componentWillMount() in React Hooks code example
Example 1: react hooks componentdidmount
// import useEffect from 'react';
useEffect(() => {
// your code here
}, []);
Example 2: componentwillunmount hooks
useEffect(() => {
window.addEventListener('mousemove', () => {});
// returned function will be called on component unmount
return () => {
window.removeEventListener('mousemove', () => {})
}
}, [])