Created
August 14, 2016 11:14
-
-
Save ream88/ff8bef62819a9a3f482be08d943a7947 to your computer and use it in GitHub Desktop.
Enhance React.Component.setState with logging
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
setState(...args) { | |
/* eslint-disable no-console */ | |
console.trace(); | |
console.group(this.constructor.name); | |
console.log("props", this.props); | |
console.log("state", this.state); | |
console.log("nextState", args[0]); | |
console.groupEnd(this.constructor.name); | |
/* eslint-enable no-console */ | |
return Component.prototype.setState.apply(this, args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment