Skip to content

Commit d824d0d

Browse files
jimfbzpao
authored andcommitted
Merge pull request facebook#6180 from camjc/master
Update PureRenderMixin docs, adding ES6 example (cherry picked from commit 1dc705a)
1 parent 4c4bfba commit d824d0d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/docs/10.8-pure-render-mixin.md

+16
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ React.createClass({
2121
});
2222
```
2323

24+
Example using ES6 class syntax:
25+
26+
```js
27+
import PureRenderMixin from 'react-addons-pure-render-mixin';
28+
class FooComponent extends React.Component {
29+
constructor(props) {
30+
super(props);
31+
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
32+
}
33+
34+
render() {
35+
return <div className={this.props.className}>foo</div>;
36+
}
37+
}
38+
```
39+
2440
Under the hood, the mixin implements [shouldComponentUpdate](/react/docs/component-specs.html#updating-shouldcomponentupdate), in which it compares the current props and state with the next ones and returns `false` if the equalities pass.
2541

2642
> Note:

0 commit comments

Comments
 (0)