New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-addons-pure-render-mixin

Package Overview
Dependencies
Maintainers
10
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-addons-pure-render-mixin - npm Package Compare versions

Comparing version 15.6.0-rc.1 to 15.6.0

react-addons-pure-render-mixin.js

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)
);
}
};

28

package.json
{
"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".
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc