Skip to content

Instantly share code, notes, and snippets.

@admataz
Created September 12, 2018 21:55
Show Gist options
  • Save admataz/5318c0bb52bf49f10d10637b607f28cb to your computer and use it in GitHub Desktop.
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
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