Created
November 3, 2015 23:02
-
-
Save squeedee/2c2fbcd81718597e67a4 to your computer and use it in GitHub Desktop.
Dealing with invalidation...
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
//= require ../actions/app | |
//= require ../stores/app | |
//= require ./form | |
var Child = React.createClass({ | |
getInitialState: function() { | |
console.log("getInitialState"); | |
return {} | |
}, | |
shouldComponentUpdate: function(nextProps) { | |
console.log(( nextProps.count % 2 === 0)); | |
return nextProps.count % 2 === 0; | |
}, | |
render: function() { | |
console.log('rendered child') | |
return (<div>{this.props.count} | |
<h1>hi</h1> | |
</div>); | |
} | |
}); | |
Pivnet.ReleaseAdmin.Components.App = React.createClass({ | |
getInitialState: function() { | |
return { count: 0 }; | |
}, | |
_click: function(event) { | |
this.setState({count: this.state.count + 1 }); | |
}, | |
render: function() { | |
return ( | |
<div> | |
<button onClick={this._click}>CLICK</button> | |
<Child count={this.state.count}/> | |
</div> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment