Created
May 6, 2019 18:16
-
-
Save YannickLeRoux/3f9f0099fd0165943a80dd3acbe28743 to your computer and use it in GitHub Desktop.
usePrevious Hook
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 usePrevious = value => { | |
const ref = useRef(); | |
useEffect(() => { | |
ref.current = value; | |
}); | |
return ref.current; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment