react-addons-pure-render-mixin

>**Note:** >This is a legacy React addon, and is no longer maintained. > >We don't encourage using it in new code, but it exists for backwards compatibility. >The recommended migration path is to use [`React.PureComponent`](https://facebook.github.io/re

MIT 62 个版本
安装
npm install react-addons-pure-render-mixin
yarn add react-addons-pure-render-mixin
pnpm add react-addons-pure-render-mixin
bun add react-addons-pure-render-mixin
README

react-addons-pure-render-mixin

Note: This is a legacy React addon, and is no longer maintained.

We don't encourage using it in new code, but it exists for backwards compatibility.
The recommended migration path is to use React.PureComponent instead.

Importing

import PureRenderMixin from 'react-addons-pure-render-mixin'; // ES6
var PureRenderMixin = require('react-addons-pure-render-mixin'); // ES5 with npm

If you prefer a <script> tag, you can get it from React.addons.PureRenderMixin with:

<!-- development version -->
<script src="https://unpkg.com/react-addons-pure-render-mixin/react-addons-pure-render-mixin.js"></script>

<!-- production version -->
<script src="https://unpkg.com/react-addons-pure-render-mixin/react-addons-pure-render-mixin.min.js"></script>

In this case, make sure to put the <script> tag after React.

Overview

If your React component's render function renders the same result given the same props and state, you can use this mixin for a performance boost in some cases.

Example:

const createReactClass = require('create-react-class');

createReactClass({
  mixins: [PureRenderMixin],

  render: function() {
    return <div className={this.props.className}>foo</div>;
  }
});

Under the hood, the mixin implements shouldComponentUpdate, in which it compares the current props and state with the next ones and returns false if the equalities pass.

Note:

This only shallowly compares the objects. If these contain complex data structures, it may produce false-negatives for deeper differences. Only mix into components which have simple props and state, or use forceUpdate() when you know deep data structures have changed. Or, consider using immutable objects to facilitate fast comparisons of nested data.

Furthermore, shouldComponentUpdate skips updates for the whole component subtree. Make sure all the children components are also "pure".

版本列表
16.0.0-alpha.3 2017-02-23
16.0.0-alpha.2 2017-02-09
16.0.0-alpha.0 2017-01-25
16.0.0-alpha 2017-01-10
15.6.3 2020-12-04
15.6.2 2017-09-26
15.6.0-rc.1 2017-06-01
15.6.0-rc.0 2017-06-13
15.6.0 2017-06-14
15.5.2 2017-04-09
15.5.1 2017-04-07
15.5.0-rc.2 2017-04-06
15.5.0-rc.1 2017-04-05
15.5.0-alpha.0 2017-03-24
15.5.0 2017-03-31
15.4.2 2017-01-06
15.4.1 2016-11-23
15.4.0-rc.4 2016-10-14
15.4.0-rc.3 2016-10-14
15.4.0-rc.2 2016-10-05
15.4.0-rc.1 2016-10-04
15.4.0 2016-11-16
15.3.2-rc.1 2016-09-15
15.3.2 2016-09-19
15.3.1-rc.2 2016-08-15
15.3.1-rc.1 2016-08-12
15.3.1 2016-08-19
15.3.0-rc.3 2016-07-21
15.3.0-rc.2 2016-07-13
15.3.0-rc.1 2016-07-13
15.3.0 2016-07-29
15.2.1 2016-07-08
15.2.0-rc.2 2016-07-01
15.2.0-rc.1 2016-06-15
15.2.0 2016-07-01
15.1.0-alpha.1 2016-05-10
15.1.0 2016-05-20
15.0.3-alpha.2 2016-05-10
15.0.3-alpha.1 2016-05-03
15.0.2-alpha.4 2016-04-28
15.0.2-alpha.3 2016-04-25
15.0.2-alpha.2 2016-04-21
15.0.2-alpha.1 2016-04-20
15.0.2 2016-04-30
15.0.1 2016-04-08
15.0.0-rc.2 2016-03-16
15.0.0-rc.1 2016-03-08
15.0.0 2016-04-07
0.15.0-alpha.1 2016-01-21
0.14.8 2016-03-29
0.14.7 2016-01-28
0.14.6 2016-01-06
0.14.5 2015-12-29
0.14.4 2015-12-29
0.14.3 2015-11-19
0.14.2 2015-11-02
0.14.1 2015-10-28
0.14.0 2015-10-07
0.14.0-rc1 2015-09-10
0.14.0-beta3 2015-08-03
0.14.0-beta2 2015-08-02
0.14.0-beta1 2015-07-03