Skip to content

Instantly share code, notes, and snippets.

@YannickLeRoux
Last active October 22, 2019 22:09
Show Gist options
  • Save YannickLeRoux/89bbed48b4c6c4aa36d203446899f881 to your computer and use it in GitHub Desktop.
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
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