Created
June 4, 2020 20:10
-
-
Save iamnnort/05f156c637129a8750e4835f1279aae5 to your computer and use it in GitHub Desktop.
How to mimic componentDidUpdate() with React Hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const App = props => { | |
const didMountRef = useRef(false) | |
useEffect(() => { | |
if (didMountRef.current) { | |
doStuff() | |
} else didMountRef.current = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment