pure-render-decorator
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -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": { |
36
test.js
@@ -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 } | ||
) | ||
); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4124
65
+ Addedfbjs@0.8.0
+ Addedbabel-plugin-syntax-flow@6.18.0(transitive)
+ Addedfbjs@0.8.0(transitive)
- Removedreact-addons-shallow-compare@15.6.3(transitive)