Socket
Socket
Sign inDemoInstall

react-redux

Package Overview
Dependencies
6
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.1 to 4.3.0

95

dist/react-redux.js

@@ -239,2 +239,7 @@ (function webpackUniversalModuleDefinition(root, factory) {

function checkStateShape(stateProps, dispatch) {
(0, _invariant2["default"])((0, _isPlainObject2["default"])(stateProps), '`%sToProps` must return an object. Instead received %s.', dispatch ? 'mapDispatch' : 'mapState', stateProps);
return stateProps;
}
// Helps track hot reloading.

@@ -247,7 +252,7 @@ var nextVersion = 0;

var shouldSubscribe = Boolean(mapStateToProps);
var finalMapStateToProps = mapStateToProps || defaultMapStateToProps;
var finalMapDispatchToProps = (0, _isPlainObject2["default"])(mapDispatchToProps) ? (0, _wrapActionCreators2["default"])(mapDispatchToProps) : mapDispatchToProps || defaultMapDispatchToProps;
var mapState = mapStateToProps || defaultMapStateToProps;
var mapDispatch = (0, _isPlainObject2["default"])(mapDispatchToProps) ? (0, _wrapActionCreators2["default"])(mapDispatchToProps) : mapDispatchToProps || defaultMapDispatchToProps;
var finalMergeProps = mergeProps || defaultMergeProps;
var doStatePropsDependOnOwnProps = finalMapStateToProps.length !== 1;
var doDispatchPropsDependOnOwnProps = finalMapDispatchToProps.length !== 1;
var checkMergedEquals = finalMergeProps !== defaultMergeProps;
var _options$pure = options.pure;

@@ -262,19 +267,2 @@ var pure = _options$pure === undefined ? true : _options$pure;

function computeStateProps(store, props) {
var state = store.getState();
var stateProps = doStatePropsDependOnOwnProps ? finalMapStateToProps(state, props) : finalMapStateToProps(state);
(0, _invariant2["default"])((0, _isPlainObject2["default"])(stateProps), '`mapStateToProps` must return an object. Instead received %s.', stateProps);
return stateProps;
}
function computeDispatchProps(store, props) {
var dispatch = store.dispatch;
var dispatchProps = doDispatchPropsDependOnOwnProps ? finalMapDispatchToProps(dispatch, props) : finalMapDispatchToProps(dispatch);
(0, _invariant2["default"])((0, _isPlainObject2["default"])(dispatchProps), '`mapDispatchToProps` must return an object. Instead received %s.', dispatchProps);
return dispatchProps;
}
function computeMergedProps(stateProps, dispatchProps, parentProps) {

@@ -310,4 +298,47 @@ var mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps);

Connect.prototype.computeStateProps = function computeStateProps(store, props) {
if (!this.finalMapStateToProps) {
return this.configureFinalMapState(store, props);
}
var state = store.getState();
var stateProps = this.doStatePropsDependOnOwnProps ? this.finalMapStateToProps(state, props) : this.finalMapStateToProps(state);
return checkStateShape(stateProps);
};
Connect.prototype.configureFinalMapState = function configureFinalMapState(store, props) {
var mappedState = mapState(store.getState(), props);
var isFactory = typeof mappedState === 'function';
this.finalMapStateToProps = isFactory ? mappedState : mapState;
this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1;
return isFactory ? this.computeStateProps(store, props) : checkStateShape(mappedState);
};
Connect.prototype.computeDispatchProps = function computeDispatchProps(store, props) {
if (!this.finalMapDispatchToProps) {
return this.configureFinalMapDispatch(store, props);
}
var dispatch = store.dispatch;
var dispatchProps = this.doDispatchPropsDependOnOwnProps ? this.finalMapDispatchToProps(dispatch, props) : this.finalMapDispatchToProps(dispatch);
return checkStateShape(dispatchProps, true);
};
Connect.prototype.configureFinalMapDispatch = function configureFinalMapDispatch(store, props) {
var mappedDispatch = mapDispatch(store.dispatch, props);
var isFactory = typeof mappedDispatch === 'function';
this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch;
this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1;
return isFactory ? this.computeDispatchProps(store, props) : checkStateShape(mappedDispatch, true);
};
Connect.prototype.updateStatePropsIfNeeded = function updateStatePropsIfNeeded() {
var nextStateProps = computeStateProps(this.store, this.props);
var nextStateProps = this.computeStateProps(this.store, this.props);
if (this.stateProps && (0, _shallowEqual2["default"])(nextStateProps, this.stateProps)) {

@@ -322,3 +353,3 @@ return false;

Connect.prototype.updateDispatchPropsIfNeeded = function updateDispatchPropsIfNeeded() {
var nextDispatchProps = computeDispatchProps(this.store, this.props);
var nextDispatchProps = this.computeDispatchProps(this.store, this.props);
if (this.dispatchProps && (0, _shallowEqual2["default"])(nextDispatchProps, this.dispatchProps)) {

@@ -332,4 +363,10 @@ return false;

Connect.prototype.updateMergedProps = function updateMergedProps() {
this.mergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props);
Connect.prototype.updateMergedPropsIfNeeded = function updateMergedPropsIfNeeded() {
var nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props);
if (this.mergedProps && checkMergedEquals && (0, _shallowEqual2["default"])(nextMergedProps, this.mergedProps)) {
return false;
}
this.mergedProps = nextMergedProps;
return true;
};

@@ -377,2 +414,4 @@

this.renderedElement = null;
this.finalMapDispatchToProps = null;
this.finalMapStateToProps = null;
};

@@ -411,4 +450,4 @@

if (pure && renderedElement) {
shouldUpdateStateProps = hasStoreStateChanged || haveOwnPropsChanged && doStatePropsDependOnOwnProps;
shouldUpdateDispatchProps = haveOwnPropsChanged && doDispatchPropsDependOnOwnProps;
shouldUpdateStateProps = hasStoreStateChanged || haveOwnPropsChanged && this.doStatePropsDependOnOwnProps;
shouldUpdateDispatchProps = haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps;
}

@@ -427,3 +466,3 @@

if (haveStatePropsChanged || haveDispatchPropsChanged || haveOwnPropsChanged) {
this.updateMergedProps();
haveMergedPropsChanged = this.updateMergedPropsIfNeeded();
} else {

@@ -430,0 +469,0 @@ haveMergedPropsChanged = false;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("redux")):"function"==typeof define&&define.amd?define(["react","redux"],e):"object"==typeof exports?exports.ReactRedux=e(require("react"),require("redux")):t.ReactRedux=e(t.React,t.Redux)}(this,function(t,e){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.connect=e.Provider=void 0;var o=r(3),s=n(o),i=r(4),u=n(i);e.Provider=s["default"],e.connect=u["default"]},function(e,r){e.exports=t},function(t,e,r){"use strict";e.__esModule=!0;var n=r(1);e["default"]=n.PropTypes.shape({subscribe:n.PropTypes.func.isRequired,dispatch:n.PropTypes.func.isRequired,getState:n.PropTypes.func.isRequired})},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0,e["default"]=void 0;var u=r(1),a=r(2),c=n(a),p=function(t){function e(r,n){o(this,e);var i=s(this,t.call(this,r,n));return i.store=r.store,i}return i(e,t),e.prototype.getChildContext=function(){return{store:this.store}},e.prototype.render=function(){var t=this.props.children;return u.Children.only(t)},e}(u.Component);e["default"]=p,p.propTypes={store:c["default"].isRequired,children:u.PropTypes.element.isRequired},p.childContextTypes={store:c["default"].isRequired}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t){return t.displayName||t.name||"Component"}function a(t,e,r){function n(t,e){var r=t.getState(),n=_?v(r,e):v(r);return(0,C["default"])((0,m["default"])(n),"`mapStateToProps` must return an object. Instead received %s.",n),n}function a(t,e){var r=t.dispatch,n=T?g(r,e):g(r);return(0,C["default"])((0,m["default"])(n),"`mapDispatchToProps` must return an object. Instead received %s.",n),n}function f(t,e,r){var n=x(t,e,r);return(0,C["default"])((0,m["default"])(n),"`mergeProps` must return an object. Instead received %s.",n),n}var l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},y=!!t,v=t||w,g=(0,m["default"])(e)?(0,b["default"])(e):e||O,x=r||S,_=1!==v.length,T=1!==g.length,R=l.pure,E=void 0===R?!0:R,M=l.withRef,I=void 0===M?!1:M,q=j++;return function(t){var e=function(e){function r(t,n){o(this,r);var i=s(this,e.call(this,t,n));i.version=q,i.store=t.store||n.store,(0,C["default"])(i.store,'Could not find "store" in either the context or '+('props of "'+i.constructor.displayName+'". ')+"Either wrap the root component in a <Provider>, "+('or explicitly pass "store" as a prop to "'+i.constructor.displayName+'".'));var u=i.store.getState();return i.state={storeState:u},i.clearCache(),i}return i(r,e),r.prototype.shouldComponentUpdate=function(){return!E||this.haveOwnPropsChanged||this.hasStoreStateChanged},r.prototype.updateStatePropsIfNeeded=function(){var t=n(this.store,this.props);return this.stateProps&&(0,h["default"])(t,this.stateProps)?!1:(this.stateProps=t,!0)},r.prototype.updateDispatchPropsIfNeeded=function(){var t=a(this.store,this.props);return this.dispatchProps&&(0,h["default"])(t,this.dispatchProps)?!1:(this.dispatchProps=t,!0)},r.prototype.updateMergedProps=function(){this.mergedProps=f(this.stateProps,this.dispatchProps,this.props)},r.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},r.prototype.trySubscribe=function(){y&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},r.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},r.prototype.componentDidMount=function(){this.trySubscribe()},r.prototype.componentWillReceiveProps=function(t){E&&(0,h["default"])(t,this.props)||(this.haveOwnPropsChanged=!0)},r.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},r.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.renderedElement=null},r.prototype.handleChange=function(){if(this.unsubscribe){var t=this.state.storeState,e=this.store.getState();E&&t===e||(this.hasStoreStateChanged=!0,this.setState({storeState:e}))}},r.prototype.getWrappedInstance=function(){return(0,C["default"])(I,"To access the wrapped instance, you need to specify { withRef: true } as the fourth argument of the connect() call."),this.refs.wrappedInstance},r.prototype.render=function(){var e=this.haveOwnPropsChanged,r=this.hasStoreStateChanged,n=this.renderedElement;this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1;var o=!0,s=!0;E&&n&&(o=r||e&&_,s=e&&T);var i=!1,u=!1;o&&(i=this.updateStatePropsIfNeeded()),s&&(u=this.updateDispatchPropsIfNeeded());var a=!0;return i||u||e?this.updateMergedProps():a=!1,!a&&n?n:this.renderedElement=I?(0,p.createElement)(t,c({},this.mergedProps,{ref:"wrappedInstance"})):(0,p.createElement)(t,this.mergedProps)},r}(p.Component);return e.displayName="Connect("+u(t)+")",e.WrappedComponent=t,e.contextTypes={store:d["default"]},e.propTypes={store:d["default"]},(0,P["default"])(e,t)}}var c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.__esModule=!0,e["default"]=a;var p=r(1),f=r(2),d=n(f),l=r(5),h=n(l),y=r(6),b=n(y),v=r(11),m=n(v),g=r(7),P=n(g),x=r(8),C=n(x),w=function(t){return{}},O=function(t){return{dispatch:t}},S=function(t,e,r){return c({},r,t,e)},j=0},function(t,e){"use strict";function r(t,e){if(t===e)return!0;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,s=0;r.length>s;s++)if(!o.call(e,r[s])||t[r[s]]!==e[r[s]])return!1;return!0}e.__esModule=!0,e["default"]=r},function(t,e,r){"use strict";function n(t){return function(e){return(0,o.bindActionCreators)(t,e)}}e.__esModule=!0,e["default"]=n;var o=r(12)},function(t,e){"use strict";var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0};t.exports=function(t,e){for(var o=Object.getOwnPropertyNames(e),s=0;o.length>s;++s)r[o[s]]||n[o[s]]||(t[o[s]]=e[o[s]]);return t}},function(t,e,r){"use strict";var n=function(t,e,r,n,o,s,i,u){if(!t){var a;if(void 0===e)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,o,s,i,u],p=0;a=Error(e.replace(/%s/g,function(){return c[p++]})),a.name="Invariant Violation"}throw a.framesToPop=1,a}};t.exports=n},function(t,e){function r(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}t.exports=r},function(t,e){function r(t){return!!t&&"object"==typeof t}t.exports=r},function(t,e,r){function n(t){if(!s(t)||p.call(t)!=i||o(t))return!1;var e=u;if("function"==typeof t.constructor&&(e=f(t)),null===e)return!0;var r=e.constructor;return"function"==typeof r&&r instanceof r&&a.call(r)==c}var o=r(9),s=r(10),i="[object Object]",u=Object.prototype,a=Function.prototype.toString,c=a.call(Object),p=u.toString,f=Object.getPrototypeOf;t.exports=n},function(t,r){t.exports=e}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("redux")):"function"==typeof define&&define.amd?define(["react","redux"],e):"object"==typeof exports?exports.ReactRedux=e(require("react"),require("redux")):t.ReactRedux=e(t.React,t.Redux)}(this,function(t,e){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.connect=e.Provider=void 0;var n=r(3),s=o(n),i=r(4),a=o(i);e.Provider=s["default"],e.connect=a["default"]},function(e,r){e.exports=t},function(t,e,r){"use strict";e.__esModule=!0;var o=r(1);e["default"]=o.PropTypes.shape({subscribe:o.PropTypes.func.isRequired,dispatch:o.PropTypes.func.isRequired,getState:o.PropTypes.func.isRequired})},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0,e["default"]=void 0;var a=r(1),p=r(2),u=o(p),c=function(t){function e(r,o){n(this,e);var i=s(this,t.call(this,r,o));return i.store=r.store,i}return i(e,t),e.prototype.getChildContext=function(){return{store:this.store}},e.prototype.render=function(){var t=this.props.children;return a.Children.only(t)},e}(a.Component);e["default"]=c,c.propTypes={store:u["default"].isRequired,children:a.PropTypes.element.isRequired},c.childContextTypes={store:u["default"].isRequired}},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(t){return t.displayName||t.name||"Component"}function p(t,e){return(0,w["default"])((0,m["default"])(t),"`%sToProps` must return an object. Instead received %s.",e?"mapDispatch":"mapState",t),t}function u(t,e,r){function o(t,e,r){var o=v(t,e,r);return(0,w["default"])((0,m["default"])(o),"`mergeProps` must return an object. Instead received %s.",o),o}var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},h=!!t,l=t||x,P=(0,m["default"])(e)?(0,b["default"])(e):e||C,v=r||T,g=v!==T,O=u.pure,_=void 0===O?!0:O,j=u.withRef,D=void 0===j?!1:j,R=M++;return function(t){var e=function(e){function r(t,o){n(this,r);var i=s(this,e.call(this,t,o));i.version=R,i.store=t.store||o.store,(0,w["default"])(i.store,'Could not find "store" in either the context or '+('props of "'+i.constructor.displayName+'". ')+"Either wrap the root component in a <Provider>, "+('or explicitly pass "store" as a prop to "'+i.constructor.displayName+'".'));var a=i.store.getState();return i.state={storeState:a},i.clearCache(),i}return i(r,e),r.prototype.shouldComponentUpdate=function(){return!_||this.haveOwnPropsChanged||this.hasStoreStateChanged},r.prototype.computeStateProps=function(t,e){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,e);var r=t.getState(),o=this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(r,e):this.finalMapStateToProps(r);return p(o)},r.prototype.configureFinalMapState=function(t,e){var r=l(t.getState(),e),o="function"==typeof r;return this.finalMapStateToProps=o?r:l,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,o?this.computeStateProps(t,e):p(r)},r.prototype.computeDispatchProps=function(t,e){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,e);var r=t.dispatch,o=this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(r,e):this.finalMapDispatchToProps(r);return p(o,!0)},r.prototype.configureFinalMapDispatch=function(t,e){var r=P(t.dispatch,e),o="function"==typeof r;return this.finalMapDispatchToProps=o?r:P,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,o?this.computeDispatchProps(t,e):p(r,!0)},r.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return this.stateProps&&(0,y["default"])(t,this.stateProps)?!1:(this.stateProps=t,!0)},r.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return this.dispatchProps&&(0,y["default"])(t,this.dispatchProps)?!1:(this.dispatchProps=t,!0)},r.prototype.updateMergedPropsIfNeeded=function(){var t=o(this.stateProps,this.dispatchProps,this.props);return this.mergedProps&&g&&(0,y["default"])(t,this.mergedProps)?!1:(this.mergedProps=t,!0)},r.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},r.prototype.trySubscribe=function(){h&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},r.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},r.prototype.componentDidMount=function(){this.trySubscribe()},r.prototype.componentWillReceiveProps=function(t){_&&(0,y["default"])(t,this.props)||(this.haveOwnPropsChanged=!0)},r.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},r.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},r.prototype.handleChange=function(){if(this.unsubscribe){var t=this.state.storeState,e=this.store.getState();_&&t===e||(this.hasStoreStateChanged=!0,this.setState({storeState:e}))}},r.prototype.getWrappedInstance=function(){return(0,w["default"])(D,"To access the wrapped instance, you need to specify { withRef: true } as the fourth argument of the connect() call."),this.refs.wrappedInstance},r.prototype.render=function(){var e=this.haveOwnPropsChanged,r=this.hasStoreStateChanged,o=this.renderedElement;this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1;var n=!0,s=!0;_&&o&&(n=r||e&&this.doStatePropsDependOnOwnProps,s=e&&this.doDispatchPropsDependOnOwnProps);var i=!1,a=!1;n&&(i=this.updateStatePropsIfNeeded()),s&&(a=this.updateDispatchPropsIfNeeded());var p=!0;return p=i||a||e?this.updateMergedPropsIfNeeded():!1,!p&&o?o:this.renderedElement=D?(0,f.createElement)(t,c({},this.mergedProps,{ref:"wrappedInstance"})):(0,f.createElement)(t,this.mergedProps)},r}(f.Component);return e.displayName="Connect("+a(t)+")",e.WrappedComponent=t,e.contextTypes={store:d["default"]},e.propTypes={store:d["default"]},(0,S["default"])(e,t)}}var c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};e.__esModule=!0,e["default"]=u;var f=r(1),h=r(2),d=o(h),l=r(5),y=o(l),P=r(6),b=o(P),v=r(11),m=o(v),g=r(7),S=o(g),O=r(8),w=o(O),x=function(t){return{}},C=function(t){return{dispatch:t}},T=function(t,e,r){return c({},r,t,e)},M=0},function(t,e){"use strict";function r(t,e){if(t===e)return!0;var r=Object.keys(t),o=Object.keys(e);if(r.length!==o.length)return!1;for(var n=Object.prototype.hasOwnProperty,s=0;r.length>s;s++)if(!n.call(e,r[s])||t[r[s]]!==e[r[s]])return!1;return!0}e.__esModule=!0,e["default"]=r},function(t,e,r){"use strict";function o(t){return function(e){return(0,n.bindActionCreators)(t,e)}}e.__esModule=!0,e["default"]=o;var n=r(12)},function(t,e){"use strict";var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0};t.exports=function(t,e){for(var n=Object.getOwnPropertyNames(e),s=0;n.length>s;++s)r[n[s]]||o[n[s]]||(t[n[s]]=e[n[s]]);return t}},function(t,e,r){"use strict";var o=function(t,e,r,o,n,s,i,a){if(!t){var p;if(void 0===e)p=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,o,n,s,i,a],c=0;p=Error(e.replace(/%s/g,function(){return u[c++]})),p.name="Invariant Violation"}throw p.framesToPop=1,p}};t.exports=o},function(t,e){function r(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}t.exports=r},function(t,e){function r(t){return!!t&&"object"==typeof t}t.exports=r},function(t,e,r){function o(t){if(!s(t)||c.call(t)!=i||n(t))return!1;var e=a;if("function"==typeof t.constructor&&(e=f(t)),null===e)return!0;var r=e.constructor;return"function"==typeof r&&r instanceof r&&p.call(r)==u}var n=r(9),s=r(10),i="[object Object]",a=Object.prototype,p=Function.prototype.toString,u=p.call(Object),c=a.toString,f=Object.getPrototypeOf;t.exports=o},function(t,r){t.exports=e}])});

@@ -56,2 +56,7 @@ 'use strict';

function checkStateShape(stateProps, dispatch) {
(0, _invariant2["default"])((0, _isPlainObject2["default"])(stateProps), '`%sToProps` must return an object. Instead received %s.', dispatch ? 'mapDispatch' : 'mapState', stateProps);
return stateProps;
}
// Helps track hot reloading.

@@ -64,7 +69,7 @@ var nextVersion = 0;

var shouldSubscribe = Boolean(mapStateToProps);
var finalMapStateToProps = mapStateToProps || defaultMapStateToProps;
var finalMapDispatchToProps = (0, _isPlainObject2["default"])(mapDispatchToProps) ? (0, _wrapActionCreators2["default"])(mapDispatchToProps) : mapDispatchToProps || defaultMapDispatchToProps;
var mapState = mapStateToProps || defaultMapStateToProps;
var mapDispatch = (0, _isPlainObject2["default"])(mapDispatchToProps) ? (0, _wrapActionCreators2["default"])(mapDispatchToProps) : mapDispatchToProps || defaultMapDispatchToProps;
var finalMergeProps = mergeProps || defaultMergeProps;
var doStatePropsDependOnOwnProps = finalMapStateToProps.length !== 1;
var doDispatchPropsDependOnOwnProps = finalMapDispatchToProps.length !== 1;
var checkMergedEquals = finalMergeProps !== defaultMergeProps;
var _options$pure = options.pure;

@@ -79,19 +84,2 @@ var pure = _options$pure === undefined ? true : _options$pure;

function computeStateProps(store, props) {
var state = store.getState();
var stateProps = doStatePropsDependOnOwnProps ? finalMapStateToProps(state, props) : finalMapStateToProps(state);
(0, _invariant2["default"])((0, _isPlainObject2["default"])(stateProps), '`mapStateToProps` must return an object. Instead received %s.', stateProps);
return stateProps;
}
function computeDispatchProps(store, props) {
var dispatch = store.dispatch;
var dispatchProps = doDispatchPropsDependOnOwnProps ? finalMapDispatchToProps(dispatch, props) : finalMapDispatchToProps(dispatch);
(0, _invariant2["default"])((0, _isPlainObject2["default"])(dispatchProps), '`mapDispatchToProps` must return an object. Instead received %s.', dispatchProps);
return dispatchProps;
}
function computeMergedProps(stateProps, dispatchProps, parentProps) {

@@ -127,4 +115,47 @@ var mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps);

Connect.prototype.computeStateProps = function computeStateProps(store, props) {
if (!this.finalMapStateToProps) {
return this.configureFinalMapState(store, props);
}
var state = store.getState();
var stateProps = this.doStatePropsDependOnOwnProps ? this.finalMapStateToProps(state, props) : this.finalMapStateToProps(state);
return checkStateShape(stateProps);
};
Connect.prototype.configureFinalMapState = function configureFinalMapState(store, props) {
var mappedState = mapState(store.getState(), props);
var isFactory = typeof mappedState === 'function';
this.finalMapStateToProps = isFactory ? mappedState : mapState;
this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1;
return isFactory ? this.computeStateProps(store, props) : checkStateShape(mappedState);
};
Connect.prototype.computeDispatchProps = function computeDispatchProps(store, props) {
if (!this.finalMapDispatchToProps) {
return this.configureFinalMapDispatch(store, props);
}
var dispatch = store.dispatch;
var dispatchProps = this.doDispatchPropsDependOnOwnProps ? this.finalMapDispatchToProps(dispatch, props) : this.finalMapDispatchToProps(dispatch);
return checkStateShape(dispatchProps, true);
};
Connect.prototype.configureFinalMapDispatch = function configureFinalMapDispatch(store, props) {
var mappedDispatch = mapDispatch(store.dispatch, props);
var isFactory = typeof mappedDispatch === 'function';
this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch;
this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1;
return isFactory ? this.computeDispatchProps(store, props) : checkStateShape(mappedDispatch, true);
};
Connect.prototype.updateStatePropsIfNeeded = function updateStatePropsIfNeeded() {
var nextStateProps = computeStateProps(this.store, this.props);
var nextStateProps = this.computeStateProps(this.store, this.props);
if (this.stateProps && (0, _shallowEqual2["default"])(nextStateProps, this.stateProps)) {

@@ -139,3 +170,3 @@ return false;

Connect.prototype.updateDispatchPropsIfNeeded = function updateDispatchPropsIfNeeded() {
var nextDispatchProps = computeDispatchProps(this.store, this.props);
var nextDispatchProps = this.computeDispatchProps(this.store, this.props);
if (this.dispatchProps && (0, _shallowEqual2["default"])(nextDispatchProps, this.dispatchProps)) {

@@ -149,4 +180,10 @@ return false;

Connect.prototype.updateMergedProps = function updateMergedProps() {
this.mergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props);
Connect.prototype.updateMergedPropsIfNeeded = function updateMergedPropsIfNeeded() {
var nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props);
if (this.mergedProps && checkMergedEquals && (0, _shallowEqual2["default"])(nextMergedProps, this.mergedProps)) {
return false;
}
this.mergedProps = nextMergedProps;
return true;
};

@@ -194,2 +231,4 @@

this.renderedElement = null;
this.finalMapDispatchToProps = null;
this.finalMapStateToProps = null;
};

@@ -228,4 +267,4 @@

if (pure && renderedElement) {
shouldUpdateStateProps = hasStoreStateChanged || haveOwnPropsChanged && doStatePropsDependOnOwnProps;
shouldUpdateDispatchProps = haveOwnPropsChanged && doDispatchPropsDependOnOwnProps;
shouldUpdateStateProps = hasStoreStateChanged || haveOwnPropsChanged && this.doStatePropsDependOnOwnProps;
shouldUpdateDispatchProps = haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps;
}

@@ -244,3 +283,3 @@

if (haveStatePropsChanged || haveDispatchPropsChanged || haveOwnPropsChanged) {
this.updateMergedProps();
haveMergedPropsChanged = this.updateMergedPropsIfNeeded();
} else {

@@ -247,0 +286,0 @@ haveMergedPropsChanged = false;

{
"name": "react-redux",
"version": "4.2.1",
"version": "4.3.0",
"description": "Official React bindings for Redux",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -30,3 +30,3 @@ React Redux

- [Quick Start](docs/quick-start.md#quick-start)
- [Redux: Usage with React](http://redux.js.org/docs/basics/UsageWithReact.html)
- [API](docs/api.md#api)

@@ -37,4 +37,9 @@ - [`<Provider store>`](docs/api.md#provider-store)

## How Does It Work?
We do a deep dive on how React Redux works in [this readthesource episode](https://www.youtube.com/watch?v=VJ38wSFbM3A).
Enjoy!
## License
MIT

@@ -21,2 +21,12 @@ import { Component, createElement } from 'react'

function checkStateShape(stateProps, dispatch) {
invariant(
isPlainObject(stateProps),
'`%sToProps` must return an object. Instead received %s.',
dispatch ? 'mapDispatch' : 'mapState',
stateProps
)
return stateProps
}
// Helps track hot reloading.

@@ -27,9 +37,9 @@ let nextVersion = 0

const shouldSubscribe = Boolean(mapStateToProps)
const finalMapStateToProps = mapStateToProps || defaultMapStateToProps
const finalMapDispatchToProps = isPlainObject(mapDispatchToProps) ?
const mapState = mapStateToProps || defaultMapStateToProps
const mapDispatch = isPlainObject(mapDispatchToProps) ?
wrapActionCreators(mapDispatchToProps) :
mapDispatchToProps || defaultMapDispatchToProps
const finalMergeProps = mergeProps || defaultMergeProps
const doStatePropsDependOnOwnProps = finalMapStateToProps.length !== 1
const doDispatchPropsDependOnOwnProps = finalMapDispatchToProps.length !== 1
const checkMergedEquals = finalMergeProps !== defaultMergeProps
const { pure = true, withRef = false } = options

@@ -40,30 +50,2 @@

function computeStateProps(store, props) {
const state = store.getState()
const stateProps = doStatePropsDependOnOwnProps ?
finalMapStateToProps(state, props) :
finalMapStateToProps(state)
invariant(
isPlainObject(stateProps),
'`mapStateToProps` must return an object. Instead received %s.',
stateProps
)
return stateProps
}
function computeDispatchProps(store, props) {
const { dispatch } = store
const dispatchProps = doDispatchPropsDependOnOwnProps ?
finalMapDispatchToProps(dispatch, props) :
finalMapDispatchToProps(dispatch)
invariant(
isPlainObject(dispatchProps),
'`mapDispatchToProps` must return an object. Instead received %s.',
dispatchProps
)
return dispatchProps
}
function computeMergedProps(stateProps, dispatchProps, parentProps) {

@@ -102,4 +84,54 @@ const mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps)

computeStateProps(store, props) {
if (!this.finalMapStateToProps) {
return this.configureFinalMapState(store, props)
}
const state = store.getState()
const stateProps = this.doStatePropsDependOnOwnProps ?
this.finalMapStateToProps(state, props) :
this.finalMapStateToProps(state)
return checkStateShape(stateProps)
}
configureFinalMapState(store, props) {
const mappedState = mapState(store.getState(), props)
const isFactory = typeof mappedState === 'function'
this.finalMapStateToProps = isFactory ? mappedState : mapState
this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1
return isFactory ?
this.computeStateProps(store, props) :
checkStateShape(mappedState)
}
computeDispatchProps(store, props) {
if (!this.finalMapDispatchToProps) {
return this.configureFinalMapDispatch(store, props)
}
const { dispatch } = store
const dispatchProps = this.doDispatchPropsDependOnOwnProps ?
this.finalMapDispatchToProps(dispatch, props) :
this.finalMapDispatchToProps(dispatch)
return checkStateShape(dispatchProps, true)
}
configureFinalMapDispatch(store, props) {
const mappedDispatch = mapDispatch(store.dispatch, props)
const isFactory = typeof mappedDispatch === 'function'
this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch
this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1
return isFactory ?
this.computeDispatchProps(store, props) :
checkStateShape(mappedDispatch, true)
}
updateStatePropsIfNeeded() {
const nextStateProps = computeStateProps(this.store, this.props)
const nextStateProps = this.computeStateProps(this.store, this.props)
if (this.stateProps && shallowEqual(nextStateProps, this.stateProps)) {

@@ -114,3 +146,3 @@ return false

updateDispatchPropsIfNeeded() {
const nextDispatchProps = computeDispatchProps(this.store, this.props)
const nextDispatchProps = this.computeDispatchProps(this.store, this.props)
if (this.dispatchProps && shallowEqual(nextDispatchProps, this.dispatchProps)) {

@@ -124,8 +156,10 @@ return false

updateMergedProps() {
this.mergedProps = computeMergedProps(
this.stateProps,
this.dispatchProps,
this.props
)
updateMergedPropsIfNeeded() {
const nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props)
if (this.mergedProps && checkMergedEquals && shallowEqual(nextMergedProps, this.mergedProps)) {
return false
}
this.mergedProps = nextMergedProps
return true
}

@@ -173,2 +207,4 @@

this.renderedElement = null
this.finalMapDispatchToProps = null
this.finalMapStateToProps = null
}

@@ -213,6 +249,6 @@

shouldUpdateStateProps = hasStoreStateChanged || (
haveOwnPropsChanged && doStatePropsDependOnOwnProps
haveOwnPropsChanged && this.doStatePropsDependOnOwnProps
)
shouldUpdateDispatchProps =
haveOwnPropsChanged && doDispatchPropsDependOnOwnProps
haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps
}

@@ -235,3 +271,3 @@

) {
this.updateMergedProps()
haveMergedPropsChanged = this.updateMergedPropsIfNeeded()
} else {

@@ -238,0 +274,0 @@ haveMergedPropsChanged = false

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc