Skip to content

Instantly share code, notes, and snippets.

@d4rkr00t
Last active December 1, 2019 23:13
Show Gist options
  • Save d4rkr00t/6647d72798c0ba4fc3c763cf7b6c087d to your computer and use it in GitHub Desktop.
Save d4rkr00t/6647d72798c0ba4fc3c763cf7b6c087d to your computer and use it in GitHub Desktop.
Why re-rendererd
componentDidUpdate(prevProps, prevState) {
Object.entries(this.props || {}).forEach(([key, val]) =>
prevProps[key] !== val && console.log(`[debug] ${this.constructor.displayName ||
this.constructor.name} prop '${key}' changed`)
);
Object.entries(this.state || {}).forEach(([key, val]) =>
prevState[key] !== val && console.log(`[debug] ${this.constructor.displayName ||
this.constructor.name} state '${key}' changed`)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment