Skip to content

Instantly share code, notes, and snippets.

@tmbtech
Forked from ryanflorence/react-logger.js
Created October 11, 2016 02:30
Show Gist options
  • Save tmbtech/538b303da7b05b4d518f0faa9a9d5cd7 to your computer and use it in GitHub Desktop.
Save tmbtech/538b303da7b05b4d518f0faa9a9d5cd7 to your computer and use it in GitHub Desktop.
// put this at the top of your app
const setState = Component.prototype.setState
Component.prototype.setState = function(nextState) {
console.group(this.constructor.name)
console.trace()
if (this.shouldComponentUpdate) {
console.log('shouldComponentUpdate', (
this.shouldComponentUpdate(this.props, nextState)
))
}
console.log('props', this.props)
console.log('state', this.state)
console.log('nextState', nextState)
console.groupEnd(this.constructor.name)
return setState.apply(this, arguments)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment