react-addons-pure-render-mixin
Advanced tools
Comparing version 15.6.0-rc.1 to 15.6.0
23
index.js
@@ -1,1 +0,22 @@ | ||
module.exports = require('react/lib/ReactComponentWithPureRenderMixin'); | ||
/** | ||
* Copyright 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
'use strict'; | ||
var shallowEqual = require('fbjs/lib/shallowEqual'); | ||
module.exports = { | ||
shouldComponentUpdate: function(nextProps, nextState) { | ||
return ( | ||
!shallowEqual(this.props, nextProps) || | ||
!shallowEqual(this.state, nextState) | ||
); | ||
} | ||
}; |
{ | ||
"name": "react-addons-pure-render-mixin", | ||
"version": "15.6.0-rc.1", | ||
"version": "15.6.0", | ||
"main": "index.js", | ||
@@ -12,8 +12,5 @@ "repository": "facebook/react", | ||
"dependencies": { | ||
"fbjs": "^0.8.9", | ||
"fbjs": "^0.8.4", | ||
"object-assign": "^4.1.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^15.6.0-rc.1" | ||
}, | ||
"files": [ | ||
@@ -23,4 +20,19 @@ "LICENSE", | ||
"README.md", | ||
"index.js" | ||
] | ||
} | ||
"index.js", | ||
"react-addons-pure-render-mixin.js", | ||
"react-addons-pure-render-mixin.min.js" | ||
], | ||
"scripts": { | ||
"test": "TEST_ENTRY=./index.js jest", | ||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./react-addons-pure-render-mixin.js jest", | ||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./react-addons-pure-render-mixin.min.js jest", | ||
"build": "npm run build:dev && npm run build:prod && node ../postbuild.js", | ||
"prepublish": "npm test && npm run build" | ||
}, | ||
"devDependencies": { | ||
"jest": "^19.0.2", | ||
"react": "^15.4.2", | ||
"react-dom": "^15.4.2", | ||
"webpack": "^2.6.1" | ||
} | ||
} |
# react-addons-pure-render-mixin | ||
This package provides the React PureRenderMixin add-on. | ||
>**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/react/docs/react-api.html#react.purecomponent) instead. | ||
See <https://facebook.github.io/react/docs/pure-render-mixin.html> for more information. | ||
**Importing** | ||
```javascript | ||
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: | ||
```html | ||
<!-- 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: | ||
```js | ||
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](https://facebook.github.io/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: | ||
> | ||
> 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](https://facebook.github.io/immutable-js/) 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". |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
14443
2
7
181
1
53
1
4
- Removedcreate-react-class@15.7.0(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@15.7.0(transitive)
- Removedreact-is@16.13.1(transitive)
Updatedfbjs@^0.8.4