use efffect in react code example
Example 1: react use effect
useEffect(() => {
},[]);
Example 2: componentdidupdate in hooks
const App = props => {
const didMountRef = useRef(false)
useEffect(() => {
if (didMountRef.current) {
doStuff()
} else didMountRef.current = true
}
}