Last active
October 22, 2019 22:09
-
-
Save YannickLeRoux/89bbed48b4c6c4aa36d203446899f881 to your computer and use it in GitHub Desktop.
can be use with useEffect to make a deep comparison instead of a reference comparison
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
function useDeepCompareMemoize(value) { | |
const ref = React.useRef() | |
if (!deepEqual(value, ref.current)) { | |
ref.current = value | |
} | |
return ref.current | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment