Created
September 12, 2018 21:55
-
-
Save admataz/5318c0bb52bf49f10d10637b607f28cb to your computer and use it in GitHub Desktop.
enhancer for recompose to log which props changed in a react component's update
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 shouldUpdate = ((props, nextProps) => { | |
console.log({props}) | |
console.log({nextProps}) | |
Object.keys(nextProps) | |
.filter(key => { | |
return nextProps[key] !== props[key] | |
}) | |
.map(key => { | |
console.log( | |
'changed property:', | |
key, | |
'from', | |
props[key], | |
'to', | |
nextProps[key] | |
) | |
}) | |
return true | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment