Last active
November 29, 2018 09:55
-
-
Save fedyk/400789c5c0fe2abaf3a6a242ebd43c17 to your computer and use it in GitHub Desktop.
what was changed
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
class App extends React.Component { | |
shouldComponentUpdate(nextProps, nextState) { | |
const nextPropsKeys = Object.keys(nextProps); | |
const nextStateKeys = Object.keys(nextState); | |
for (let i = 0; i < nextPropsKeys.length; i++) { | |
const key = nextPropsKeys[i]; | |
if (nextProps[key] !== this.props[key]) { | |
console.log(`App: props.${key} has changed`); | |
} | |
} | |
for (let i = 0; i < nextStateKeys.length; i++) { | |
const key = nextPropsKeys[i]; | |
if (nextState[key] !== this.state[key]) { | |
console.log(`App: state.${key} has changed`); | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment