Created
April 20, 2019 18:08
-
-
Save m1010j/0ab925da6fbd8ae4a1fa03614e8fbd6a to your computer and use it in GitHub Desktop.
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
function RefHooksComponent(props) { | |
const ref = useRef(null); | |
if (ref.current === null) { | |
ref.current = expensiveCalculation(props.arg); | |
} | |
const result = ref.current; | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment