Last active
November 17, 2019 04:21
-
-
Save simbathesailor/6defb45314a6015bc1c74a7fb738ba12 to your computer and use it in GitHub Desktop.
consumeuseprevious.jsx
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
const previousA = usePrevious(a); | |
const previousB = usePrevious(b); | |
const previousC = usePrevious(c); | |
useEffect(() => { | |
if (previousA !== a) { | |
console.log(`a has changed from ${previousA} to ${a}`); | |
} | |
if (previousB !== b) { | |
console.log(`a has changed from ${previousB} to ${b}`); | |
} | |
if (previousC !== c) { | |
console.log(`a has changed from ${previousC} to ${c}`); | |
} | |
}, [a, b, c]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment