From d824d0d03b529c315dfcfdeedd86328dbaec9adf Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 4 Mar 2016 16:06:31 -0800 Subject: [PATCH] Merge pull request #6180 from camjc/master Update PureRenderMixin docs, adding ES6 example (cherry picked from commit 1dc705aa0bd3200aeeb90c355e2679de0283a7af) --- docs/docs/10.8-pure-render-mixin.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/docs/10.8-pure-render-mixin.md b/docs/docs/10.8-pure-render-mixin.md index bd5143c7e3..5b8c4099f8 100644 --- a/docs/docs/10.8-pure-render-mixin.md +++ b/docs/docs/10.8-pure-render-mixin.md @@ -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
foo
; + } +} +``` + 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: