Skip to content

Instantly share code, notes, and snippets.

@coodoo
Created August 29, 2019 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coodoo/12b7638978f40c9e728dd684912d6f68 to your computer and use it in GitHub Desktop.
Save coodoo/12b7638978f40c9e728dd684912d6f68 to your computer and use it in GitHub Desktop.
[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