Created
December 13, 2018 20:08
-
-
Save mykwillis/7c15d9dc7cb3ef1537b2fe84faad290a to your computer and use it in GitHub Desktop.
See what state changed in React componentDidUpdate
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
componentDidUpdate(_: *, prevState: PlayActionState) { | |
const diff = Object.keys(this.state).reduce((d, key) => { | |
if (prevState[key] === this.state[key]) return d; | |
return { | |
...d, | |
[key]: this.state[key], | |
}; | |
}, {}); | |
console.log(diff); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment