Skip to content

Instantly share code, notes, and snippets.

@coodoo

coodoo/useEffect.js

Created Aug 29, 2019
Embed
What would you like to do?
[Request for comment] Is there any potential issues handling componentDidMount and componentDidUp with useHooks in this manner?
const once = useRef(false)
useEffect(() => {
if(once.current === false){
once.current = true
// do things as were in componentDidMount
return
}
// do things as were in componentDidUpdate
// clean up
return () => {
//
}
}) // <- no need to pass in 2nd argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment