react-side-effect
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,3 +0,2 @@ | ||
import React, { Component } from 'react'; | ||
import shallowEqual from 'shallowequal'; | ||
import React, { PureComponent } from 'react'; | ||
@@ -65,7 +64,7 @@ function _defineProperty(obj, key, value) { | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inheritsLoose(SideEffect, _Component); | ||
function (_PureComponent) { | ||
_inheritsLoose(SideEffect, _PureComponent); | ||
function SideEffect() { | ||
return _Component.apply(this, arguments) || this; | ||
return _PureComponent.apply(this, arguments) || this; | ||
} | ||
@@ -92,6 +91,2 @@ | ||
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) { | ||
return !shallowEqual(nextProps, this.props); | ||
}; | ||
_proto.UNSAFE_componentWillMount = function UNSAFE_componentWillMount() { | ||
@@ -117,3 +112,3 @@ mountedInstances.push(this); | ||
return SideEffect; | ||
}(Component); | ||
}(PureComponent); | ||
@@ -120,0 +115,0 @@ _defineProperty(SideEffect, "displayName", "SideEffect(" + getDisplayName(WrappedComponent) + ")"); |
@@ -7,3 +7,2 @@ 'use strict'; | ||
var React__default = _interopDefault(React); | ||
var shallowEqual = _interopDefault(require('shallowequal')); | ||
@@ -71,7 +70,7 @@ function _defineProperty(obj, key, value) { | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inheritsLoose(SideEffect, _Component); | ||
function (_PureComponent) { | ||
_inheritsLoose(SideEffect, _PureComponent); | ||
function SideEffect() { | ||
return _Component.apply(this, arguments) || this; | ||
return _PureComponent.apply(this, arguments) || this; | ||
} | ||
@@ -98,6 +97,2 @@ | ||
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) { | ||
return !shallowEqual(nextProps, this.props); | ||
}; | ||
_proto.UNSAFE_componentWillMount = function UNSAFE_componentWillMount() { | ||
@@ -123,3 +118,3 @@ mountedInstances.push(this); | ||
return SideEffect; | ||
}(React.Component); | ||
}(React.PureComponent); | ||
@@ -126,0 +121,0 @@ _defineProperty(SideEffect, "displayName", "SideEffect(" + getDisplayName(WrappedComponent) + ")"); |
@@ -30,49 +30,2 @@ (function (global, factory) { | ||
// | ||
var shallowequal = function shallowEqual(objA, objB, compare, compareContext) { | ||
var ret = compare ? compare.call(compareContext, objA, objB) : void 0; | ||
if (ret !== void 0) { | ||
return !!ret; | ||
} | ||
if (objA === objB) { | ||
return true; | ||
} | ||
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) { | ||
return false; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) { | ||
return false; | ||
} | ||
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); | ||
// Test for A's keys different from B. | ||
for (var idx = 0; idx < keysA.length; idx++) { | ||
var key = keysA[idx]; | ||
if (!bHasOwnProperty(key)) { | ||
return false; | ||
} | ||
var valueA = objA[key]; | ||
var valueB = objB[key]; | ||
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0; | ||
if (ret === false || (ret === void 0 && valueA !== valueB)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); | ||
@@ -118,7 +71,7 @@ function withSideEffect(reducePropsToState, handleStateChangeOnClient, mapStateOnServer) { | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inheritsLoose(SideEffect, _Component); | ||
function (_PureComponent) { | ||
_inheritsLoose(SideEffect, _PureComponent); | ||
function SideEffect() { | ||
return _Component.apply(this, arguments) || this; | ||
return _PureComponent.apply(this, arguments) || this; | ||
} | ||
@@ -145,6 +98,2 @@ | ||
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) { | ||
return !shallowequal(nextProps, this.props); | ||
}; | ||
_proto.UNSAFE_componentWillMount = function UNSAFE_componentWillMount() { | ||
@@ -170,3 +119,3 @@ mountedInstances.push(this); | ||
return SideEffect; | ||
}(React.Component); | ||
}(React.PureComponent); | ||
@@ -173,0 +122,0 @@ _defineProperty(SideEffect, "displayName", "SideEffect(" + getDisplayName(WrappedComponent) + ")"); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).withSideEffect=t(e.React)}(this,function(e){"use strict";var t="default"in e?e.default:e;function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=function(e,t,n,r){var o=n?n.call(r,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),u=Object.keys(t);if(i.length!==u.length)return!1;for(var c=Object.prototype.hasOwnProperty.bind(t),f=0;f<i.length;f++){var a=i[f];if(!c(a))return!1;var p=e[a],d=t[a];if(!1===(o=n?n.call(r,p,d,a):void 0)||void 0===o&&p!==d)return!1}return!0},o=!("undefined"==typeof window||!window.document||!window.document.createElement);return function(i,u,c){if("function"!=typeof i)throw new Error("Expected reducePropsToState to be a function.");if("function"!=typeof u)throw new Error("Expected handleStateChangeOnClient to be a function.");if(void 0!==c&&"function"!=typeof c)throw new Error("Expected mapStateOnServer to either be undefined or a function.");return function(f){if("function"!=typeof f)throw new Error("Expected WrappedComponent to be a React component.");var a,p=[];function d(){a=i(p.map(function(e){return e.props})),l.canUseDOM?u(a):c&&(a=c(a))}var l=function(e){var n,o;function i(){return e.apply(this,arguments)||this}o=e,(n=i).prototype=Object.create(o.prototype),n.prototype.constructor=n,n.__proto__=o,i.peek=function(){return a},i.rewind=function(){if(i.canUseDOM)throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");var e=a;return a=void 0,p=[],e};var u=i.prototype;return u.shouldComponentUpdate=function(e){return!r(e,this.props)},u.UNSAFE_componentWillMount=function(){p.push(this),d()},u.componentDidUpdate=function(){d()},u.componentWillUnmount=function(){var e=p.indexOf(this);p.splice(e,1),d()},u.render=function(){return t.createElement(f,this.props)},i}(e.Component);return n(l,"displayName","SideEffect("+function(e){return e.displayName||e.name||"Component"}(f)+")"),n(l,"canUseDOM",o),l}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).withSideEffect=t(e.React)}(this,function(e){"use strict";var t="default"in e?e.default:e;function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=!("undefined"==typeof window||!window.document||!window.document.createElement);return function(r,i,c){if("function"!=typeof r)throw new Error("Expected reducePropsToState to be a function.");if("function"!=typeof i)throw new Error("Expected handleStateChangeOnClient to be a function.");if(void 0!==c&&"function"!=typeof c)throw new Error("Expected mapStateOnServer to either be undefined or a function.");return function(u){if("function"!=typeof u)throw new Error("Expected WrappedComponent to be a React component.");var f,a=[];function p(){f=r(a.map(function(e){return e.props})),d.canUseDOM?i(f):c&&(f=c(f))}var d=function(e){var n,o;function r(){return e.apply(this,arguments)||this}o=e,(n=r).prototype=Object.create(o.prototype),n.prototype.constructor=n,n.__proto__=o,r.peek=function(){return f},r.rewind=function(){if(r.canUseDOM)throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");var e=f;return f=void 0,a=[],e};var i=r.prototype;return i.UNSAFE_componentWillMount=function(){a.push(this),p()},i.componentDidUpdate=function(){p()},i.componentWillUnmount=function(){var e=a.indexOf(this);a.splice(e,1),p()},i.render=function(){return t.createElement(u,this.props)},r}(e.PureComponent);return n(d,"displayName","SideEffect("+function(e){return e.displayName||e.name||"Component"}(u)+")"),n(d,"canUseDOM",o),d}}}); |
{ | ||
"name": "react-side-effect", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Create components whose prop changes map to a global side effect", | ||
@@ -34,17 +34,14 @@ "main": "lib/index.js", | ||
"peerDependencies": { | ||
"react": "^16.9.0" | ||
"react": "^16.3.0" | ||
}, | ||
"dependencies": { | ||
"shallowequal": "^1.0.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/cli": "7.0.0", | ||
"@babel/core": "7.0.0", | ||
"@babel/node": "7.0.0", | ||
"@babel/plugin-proposal-class-properties": "7.0.0", | ||
"@babel/plugin-proposal-object-rest-spread": "7.0.0", | ||
"@babel/preset-env": "7.0.0", | ||
"@babel/preset-react": "7.0.0", | ||
"@babel/register": "7.0.0", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/node": "^7.5.5", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/register": "^7.5.5", | ||
"babel-plugin-add-module-exports": "^1.0.2", | ||
"chai": "^3.2.0", | ||
@@ -64,4 +61,2 @@ "create-react-class": "^15.6.3", | ||
"rollup-plugin-babel": "^4.0.0", | ||
"rollup-plugin-commonjs": "^8.3.0", | ||
"rollup-plugin-node-resolve": "^3.0.3", | ||
"rollup-plugin-uglify": "^3.0.0" | ||
@@ -68,0 +63,0 @@ }, |
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
1
23
20586
298
- Removedshallowequal@^1.0.1
- Removedshallowequal@1.1.0(transitive)