@samitouri / QOS-React-2 / commits / 9fff1693f6

Update PureRenderMixin docs, adding ES6 example

Cameron Chamberlain committed Mar 4, 2016 at 14:52 UTC 9fff1693f64ece607ccd0670fc57d1aec236a29a
1 file changed +16
docs/docs/10.8-pure-render-mixin.md
+16
@@ -21,6 +21,22 @@ React.createClass({
21 });
22 ```
23
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 +
40 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.
41
42 > Note: