Created
March 8, 2019 06:05
-
-
Save adamgajzlerowicz/32a3a10599623ec8987a902a3928d3d4 to your computer and use it in GitHub Desktop.
check performance issues
This file contains hidden or 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
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