Created
October 1, 2019 15:04
-
-
Save honzabrecka/822ce7f4c62a2ff7287443c0de3e7ba4 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
import { useEffect } from 'react' | |
export default function useReference(lazyRefCreator, deps) { | |
const ref = useRef() | |
useEffect(() => { | |
ref.current = lazyRefCreator() | |
}, deps) | |
return ref.current | |
} | |
const x = useMemo(() => ..., []) | |
const x = useReference(() => ..., []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useMemoLast
useMemoPrev