Created
June 23, 2017 16:48
-
-
Save Willmo36/f1db03b745e49f33edebfb0c8d319c7e to your computer and use it in GitHub Desktop.
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
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