Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 adamgajzlerowicz/32a3a10599623ec8987a902a3928d3d4 to your computer and use it in GitHub Desktop.
Save adamgajzlerowicz/32a3a10599623ec8987a902a3928d3d4 to your computer and use it in GitHub Desktop.
check performance issues
import { PureComponent } from 'react';
PureComponent.componentDidUpdate = prevProps => {
const name =
this.constructor.displayName || this.constructor.name || 'Component';
console.group(name);
Object.keys(prevProps).forEach(key => {
if (prevProps[key] !== this.props[key]) {
console.log(
`property ${key} changed from ${prevProps[key]} to ${
this.props[key]
}`
);
}
});
console.groupEnd(name);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment