execute after useeffect code example
Example 1: react run useeffect only once
useEffect(() => {
// Initialization code comes here
}, []);
Example 2: useEffectOnce
import {useEffectOnce} from 'react-use';
const Demo = () => {
useEffectOnce(() => {
console.log('Running effect once on mount')
return () => {
console.log('Running clean-up of effect on unmount')
}
});
return null;
};