Skip to content

Instantly share code, notes, and snippets.

@ream88
Created August 14, 2016 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ream88/ff8bef62819a9a3f482be08d943a7947 to your computer and use it in GitHub Desktop.
Save ream88/ff8bef62819a9a3f482be08d943a7947 to your computer and use it in GitHub Desktop.
Enhance React.Component.setState with logging
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