Created
August 18, 2020 00:37
-
-
Save koba04/09a2d9c0563a2b8ecd6a10cb106cf369 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Foo = () => { | |
const someRef = React.useRef<{ someSetupMethod: () => void; someCleanupMethod: () => void }>(null) | |
React.useEffect(() => { | |
if (someRef.current === null) return | |
someRef.current.someSetupMethod() | |
return () => { | |
if (someRef.current === null) return | |
// react-hooks/exhaustive-deps warns this | |
someRef.current.someCleanupMethod() | |
} | |
}) | |
return <div>foo</div> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment