mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 20:53:08 +00:00
Update PureRenderMixin docs, adding ES6 example
This commit is contained in:
committed by
Cameron Chamberlain
parent
d98360ae9f
commit
769a6004ac
@@ -21,6 +21,22 @@ React.createClass({
|
||||
});
|
||||
```
|
||||
|
||||
Example using ES6 class syntax:
|
||||
|
||||
```js
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||
class FooComponent extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div className={this.props.className}>foo</div>;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
> Note:
|
||||
|
||||
Reference in New Issue
Block a user