Skip to content

Instantly share code, notes, and snippets.

@jchris
Created January 16, 2014 18:17
Show Gist options
  • Save jchris/8460290 to your computer and use it in GitHub Desktop.
Save jchris/8460290 to your computer and use it in GitHub Desktop.
you implement this.setStateForProps(newProps, oldProps) and call this.setState() from there
exports.StateForPropsMixin = {
componentWillReceiveProps: function(newProps) {
// console.log("StateForPropsMixin componentWillReceiveProps", newProps, this.props)
this.setStateForProps(newProps, this.props)
},
componentWillMount: function() {
// console.log("StateForPropsMixin componentWillMount", this.props)
this.setStateForProps(this.props)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment