Skip to content

Instantly share code, notes, and snippets.

@Willmo36
Created June 23, 2017 16:48
Show Gist options
  • Save Willmo36/f1db03b745e49f33edebfb0c8d319c7e to your computer and use it in GitHub Desktop.
Save Willmo36/f1db03b745e49f33edebfb0c8d319c7e to your computer and use it in GitHub Desktop.
componentWillReceiveProps(nextProps){
console.info("New props, about to render...");
Object.keys(nextProps).forEach((p) => {
console.info(`${p} is the same: ${this.props[p] === nextProps[p]}`);
});
const shouldIUsePureRender = Object.keys(nextProps).reduce((acc, p) => {
if (nextProps[p] !== this.props[p]) {
return false;
}
return acc;
}, true);
if (shouldIUsePureRender === true) {
console.info(`${this.displayName} None of the props have changed but I'm still about to render. Use the pure render mixin.`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment