Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pure-render-decorator

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-render-decorator - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

6

index.js

@@ -7,6 +7,4 @@ /**

var shallowCompare = require('react-addons-shallow-compare');
var shallowEqual = require('fbjs/lib/shallowEqual');
/**

@@ -20,3 +18,3 @@ * Tells if a component should update given it's next props

function shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
}

@@ -23,0 +21,0 @@

{
"name": "pure-render-decorator",
"version": "1.0.0",
"version": "1.0.1",
"description": "Makes React components pure.",

@@ -19,3 +19,3 @@ "keywords": [

"dependencies": {
"react-addons-shallow-compare": "^15.0.0 || ^0.14.0"
"fbjs": "0.8.0"
},

@@ -22,0 +22,0 @@ "devDependencies": {

@@ -7,8 +7,5 @@ /**

var shallowCompare = require('react-addons-shallow-compare');
var assert = require('assert');
var decorate = require('./index');
/**

@@ -25,5 +22,2 @@ *

/**
*
*/
it('should add a method named shouldComponentUpdate', function() {

@@ -34,23 +28,23 @@ assert.ok('shouldComponentUpdate' in component);

/**
*
*/
it('should use shallowCompare to compare props and state', function() {
assert.equal(
component.shouldComponentUpdate({}, {}),
shallowCompare(component, {}, {})
);
it('should return true if the props and state are different', function() {
assert.ok(component.shouldComponentUpdate({}, {}));
});
assert.equal(
component.shouldComponentUpdate(
it('should return false if the props and state are reference-equals', function() {
assert.ok(
!component.shouldComponentUpdate(
component.props,
component.state
),
shallowCompare(
component,
component.props,
component.state
)
);
});
it('should return false if props and state are shallow-equals but different references', function() {
assert.ok(
!component.shouldComponentUpdate(
{ foo: 1 },
{ bar: 2 }
)
);
});
});
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