Suppose I have the following pairing of parent and child components in React:
var ChildComponent = React.createClass({
getDefaultProps: function(){
r
When React re-renders ParentComponent
it will automatically re-render ChildComponent
. The only way to get around is to implement shouldComponentUpdate
in the ChildComponent
. You should compare this.props.a
, this.props.b
and this.props.c
and ChildComponents
own state to decide to re-render or not. If you are using immutable data than you can just compare previous and next state and props using strict equality ===
.
There are a few thing to note with your code
forceUpdate
when you setState
. React automatically does it for you.You probably meant: