Skip to content

Instantly share code, notes, and snippets.

@squeedee
Created November 3, 2015 23:02
Show Gist options
  • Save squeedee/2c2fbcd81718597e67a4 to your computer and use it in GitHub Desktop.
Save squeedee/2c2fbcd81718597e67a4 to your computer and use it in GitHub Desktop.
Dealing with invalidation...
//= 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