Created
August 29, 2019 05:26
-
-
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?
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 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