Created
September 18, 2015 14:46
-
-
Save Prinzhorn/ceb2156f8570a3745dd8 to your computer and use it in GitHub Desktop.
Quick and dirty way to debug which prop/state changes caused react update
This file contains 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
componentDidUpdate: function(prevProps, prevState) { | |
var differentProps = {}; | |
var differentState = {}; | |
var k; | |
for(k in prevProps) { | |
if(prevProps[k] !== this.props[k]) { | |
differentProps[k] = [prevProps[k], this.props[k]]; | |
} | |
} | |
for(k in this.props) { | |
if(prevProps[k] !== this.props[k]) { | |
differentProps[k] = [prevProps[k], this.props[k]]; | |
} | |
} | |
for(k in prevState) { | |
if(prevState[k] !== this.state[k]) { | |
differentState[k] = [prevState[k], this.state[k]]; | |
} | |
} | |
for(k in this.state) { | |
if(prevState[k] !== this.state[k]) { | |
differentState[k] = [prevState[k], this.state[k]]; | |
} | |
} | |
console.log(differentProps, differentState); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment