Socket
Socket
Sign inDemoInstall

react-redux

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-redux - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

53

dist/react-redux.js

@@ -192,2 +192,5 @@ (function webpackUniversalModuleDefinition(root, factory) {

// Helps track hot reloading.
var nextVersion = 0;
function createConnect(React) {

@@ -199,9 +202,10 @@ var Component = React.Component;

return function connect() {
var mapStateToProps = arguments.length <= 0 || arguments[0] === undefined ? defaultMapStateToProps : arguments[0];
var actionCreatorsOrMapDispatchToProps = arguments.length <= 1 || arguments[1] === undefined ? defaultMapDispatchToProps : arguments[1];
var mergeProps = arguments.length <= 2 || arguments[2] === undefined ? defaultMergeProps : arguments[2];
return function connect(mapStateToProps, mapDispatchToProps, mergeProps) {
var shouldSubscribe = Boolean(mapStateToProps);
var finalMapStateToProps = mapStateToProps || defaultMapStateToProps;
var finalMapDispatchToProps = _utilsIsPlainObject2['default'](mapDispatchToProps) ? _utilsWrapActionCreators2['default'](mapDispatchToProps) : mapDispatchToProps || defaultMapDispatchToProps;
var finalMergeProps = mergeProps || defaultMergeProps;
var shouldSubscribe = mapStateToProps !== defaultMapStateToProps;
var mapDispatchToProps = _utilsIsPlainObject2['default'](actionCreatorsOrMapDispatchToProps) ? _utilsWrapActionCreators2['default'](actionCreatorsOrMapDispatchToProps) : actionCreatorsOrMapDispatchToProps;
// Helps track hot reloading.
var version = nextVersion++;

@@ -236,2 +240,3 @@ return function (DecoratedComponent) {

_Component.call(this, props, context);
this.version = version;
this.setUnderlyingRef = this.setUnderlyingRef.bind(this);

@@ -245,4 +250,4 @@ this.state = _extends({}, this.mapState(props, context), this.mapDispatch(context));

Connect.prototype.componentDidMount = function componentDidMount() {
if (shouldSubscribe) {
Connect.prototype.trySubscribe = function trySubscribe() {
if (shouldSubscribe && !this.unsubscribe) {
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this));

@@ -252,8 +257,32 @@ }

Connect.prototype.componentWillUnmount = function componentWillUnmount() {
Connect.prototype.tryUnsubscribe = function tryUnsubscribe() {
if (this.isSubscribed()) {
this.unsubscribe();
this.unsubscribe = null;
}
};
Connect.prototype.componentDidMount = function componentDidMount() {
this.trySubscribe();
};
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
if (true) {
if (this.version === version) {
return;
}
// We are hot reloading!
this.version = version;
// Update the state and bindings.
this.trySubscribe();
this.setState(_extends({}, this.mapState(), this.mapDispatch()));
}
};
Connect.prototype.componentWillUnmount = function componentWillUnmount() {
this.tryUnsubscribe();
};
Connect.prototype.handleChange = function handleChange() {

@@ -273,3 +302,3 @@ var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0];

var state = context.store.getState();
var stateProps = mapStateToProps(state);
var stateProps = finalMapStateToProps(state);

@@ -285,3 +314,3 @@ _invariant2['default'](_utilsIsPlainObject2['default'](stateProps), '`mapStateToProps` must return an object. Instead received %s.', stateProps);

var dispatchProps = mapDispatchToProps(dispatch);
var dispatchProps = finalMapDispatchToProps(dispatch);

@@ -299,3 +328,3 @@ _invariant2['default'](_utilsIsPlainObject2['default'](dispatchProps), '`mapDispatchToProps` must return an object. Instead received %s.', dispatchProps);

var merged = mergeProps(stateProps, dispatchProps, props);
var merged = finalMergeProps(stateProps, dispatchProps, props);

@@ -302,0 +331,0 @@ _invariant2['default'](_utilsIsPlainObject2['default'](merged), '`mergeProps` must return an object. Instead received %s.', merged);

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("redux")):"function"==typeof define&&define.amd?define(["react","redux"],t):"object"==typeof exports?exports.ReactRedux=t(require("react"),require("redux")):e.ReactRedux=t(e.React,e.Redux)}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=r(10),u=n(o),i=r(2),s=n(i),a=s.default(u.default),c=a.Provider,f=a.connect;t.Provider=c,t.connect=f},function(e,t){"use strict";function r(e){return e.shape({subscribe:e.func.isRequired,dispatch:e.func.isRequired,getState:e.func.isRequired})}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=i.default(e),r=a.default(e);return{Provider:t,connect:r}}t.__esModule=!0,t.default=o;var u=r(4),i=n(u),s=r(3),a=n(s);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){return e.displayName||e.name||"Component"}function s(e,t){var r=e===t;return r||"object"!=typeof e||"object"!=typeof t?r:m.default(e,t)}function a(e){var t=e.Component,r=e.PropTypes,n=l.default(r);return function(){var r=arguments.length<=0||void 0===arguments[0]?P:arguments[0],a=arguments.length<=1||void 0===arguments[1]?R:arguments[1],p=arguments.length<=2||void 0===arguments[2]?w:arguments[2],l=r!==P,d=b.default(a)?x.default(a):a;return function(a){return function(t){function y(e,r){o(this,y),t.call(this,e,r),this.setUnderlyingRef=this.setUnderlyingRef.bind(this),this.state=f({},this.mapState(e,r),this.mapDispatch(r))}return u(y,t),y.prototype.shouldComponentUpdate=function(e,t){return this.isSubscribed()&&!s(this.state.stateProps,t.stateProps)||!h.default(this.props,e)},c(y,null,[{key:"displayName",value:"Connect("+i(a)+")",enumerable:!0},{key:"DecoratedComponent",value:a,enumerable:!0},{key:"contextTypes",value:{store:n.isRequired},enumerable:!0}]),y.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},y.prototype.componentDidMount=function(){l&&(this.unsubscribe=this.context.store.subscribe(this.handleChange.bind(this)))},y.prototype.componentWillUnmount=function(){this.isSubscribed()&&this.unsubscribe()},y.prototype.handleChange=function(){var e=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],t=this.mapState(e,this.context);s(this.state.stateProps,t.stateProps)||this.setState(t)},y.prototype.mapState=function(){var e=(arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],arguments.length<=1||void 0===arguments[1]?this.context:arguments[1]),t=e.store.getState(),n=r(t);return j.default(b.default(n),"`mapStateToProps` must return an object. Instead received %s.",n),{stateProps:n}},y.prototype.mapDispatch=function(){var e=arguments.length<=0||void 0===arguments[0]?this.context:arguments[0],t=e.store.dispatch,r=d(t);return j.default(b.default(r),"`mapDispatchToProps` must return an object. Instead received %s.",r),{dispatchProps:r}},y.prototype.merge=function(){var e=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],t=arguments.length<=1||void 0===arguments[1]?this.state:arguments[1],r=t.stateProps,n=t.dispatchProps,o=p(r,n,e);return j.default(b.default(o),"`mergeProps` must return an object. Instead received %s.",o),o},y.prototype.getUnderlyingRef=function(){return this.underlyingRef},y.prototype.setUnderlyingRef=function(e){this.underlyingRef=e},y.prototype.render=function(){return e.createElement(a,f({ref:this.setUnderlyingRef},this.merge()))},y}(t)}}}t.__esModule=!0;var c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=a;var p=r(1),l=n(p),d=r(7),h=n(d),y=r(6),m=n(y),g=r(5),b=n(g),v=r(8),x=n(v),_=r(9),j=n(_),P=function(){return{}},R=function(e){return{dispatch:e}},w=function(e,t,r){return f({},r,e,t)};e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,r=e.PropTypes,n=c.default(r);return function(e){function t(r,n){o(this,t),e.call(this,r,n),this.state={store:r.store}}return u(t,e),t.prototype.getChildContext=function(){return{store:this.state.store}},s(t,null,[{key:"childContextTypes",value:{store:n.isRequired},enumerable:!0},{key:"propTypes",value:{children:r.func.isRequired},enumerable:!0}]),t.prototype.componentWillReceiveProps=function(e){var t=this.state.store,r=e.store;if(t!==r){var n=r.getReducer();t.replaceReducer(n)}},t.prototype.render=function(){var e=this.props.children;return e()},t}(t)}t.__esModule=!0;var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=i;var a=r(1),c=n(a);e.exports=t.default},function(e,t){"use strict";function r(e){if(!e||"object"!=typeof e)return!1;var t="function"==typeof e.constructor?Object.getPrototypeOf(e):Object.prototype;if(null===t)return!0;var r=t.constructor;return"function"==typeof r&&r instanceof r&&n(r)===n(Object)}t.__esModule=!0,t.default=r;var n=function(e){return Function.prototype.toString.call(e)};e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++)if(!o.call(t,r[u])||e[r[u]]!==t[r[u]])return!1;return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++){if(!o.call(t,r[u]))return!1;var i=e[r[u]],s=t[r[u]];if(i!==s||"object"==typeof i||"object"==typeof s)return!1}return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return function(t){return o.bindActionCreators(e,t)}}t.__esModule=!0,t.default=n;var o=r(11);e.exports=t.default},function(e,t,r){"use strict";var n=function(e,t,r,n,o,u,i,s){if(!e){var a;if(void 0===t)a=new 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,u,i,s],f=0;a=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return c[f++]}))}throw a.framesToPop=1,a}};e.exports=n},function(t,r){t.exports=e},function(e,r){e.exports=t}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("redux")):"function"==typeof define&&define.amd?define(["react","redux"],t):"object"==typeof exports?exports.ReactRedux=t(require("react"),require("redux")):e.ReactRedux=t(e.React,e.Redux)}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=r(10),u=n(o),i=r(2),s=n(i),a=s.default(u.default),c=a.Provider,f=a.connect;t.Provider=c,t.connect=f},function(e,t){"use strict";function r(e){return e.shape({subscribe:e.func.isRequired,dispatch:e.func.isRequired,getState:e.func.isRequired})}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=i.default(e),r=a.default(e);return{Provider:t,connect:r}}t.__esModule=!0,t.default=o;var u=r(4),i=n(u),s=r(3),a=n(s);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){return e.displayName||e.name||"Component"}function s(e,t){var r=e===t;return r||"object"!=typeof e||"object"!=typeof t?r:b.default(e,t)}function a(e){var t=e.Component,r=e.PropTypes,n=l.default(r);return function(r,a,p){var l=Boolean(r),d=r||P,y=v.default(a)?x.default(a):a||R,b=p||w,m=O++;return function(r){return function(t){function a(e,r){o(this,a),t.call(this,e,r),this.version=m,this.setUnderlyingRef=this.setUnderlyingRef.bind(this),this.state=f({},this.mapState(e,r),this.mapDispatch(r))}return u(a,t),a.prototype.shouldComponentUpdate=function(e,t){return this.isSubscribed()&&!s(this.state.stateProps,t.stateProps)||!h.default(this.props,e)},c(a,null,[{key:"displayName",value:"Connect("+i(r)+")",enumerable:!0},{key:"DecoratedComponent",value:r,enumerable:!0},{key:"contextTypes",value:{store:n.isRequired},enumerable:!0}]),a.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},a.prototype.trySubscribe=function(){l&&!this.unsubscribe&&(this.unsubscribe=this.context.store.subscribe(this.handleChange.bind(this)))},a.prototype.tryUnsubscribe=function(){this.isSubscribed()&&(this.unsubscribe(),this.unsubscribe=null)},a.prototype.componentDidMount=function(){this.trySubscribe()},a.prototype.componentWillUpdate=function(){},a.prototype.componentWillUnmount=function(){this.tryUnsubscribe()},a.prototype.handleChange=function(){var e=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],t=this.mapState(e,this.context);s(this.state.stateProps,t.stateProps)||this.setState(t)},a.prototype.mapState=function(){var e=(arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],arguments.length<=1||void 0===arguments[1]?this.context:arguments[1]),t=e.store.getState(),r=d(t);return j.default(v.default(r),"`mapStateToProps` must return an object. Instead received %s.",r),{stateProps:r}},a.prototype.mapDispatch=function(){var e=arguments.length<=0||void 0===arguments[0]?this.context:arguments[0],t=e.store.dispatch,r=y(t);return j.default(v.default(r),"`mapDispatchToProps` must return an object. Instead received %s.",r),{dispatchProps:r}},a.prototype.merge=function(){var e=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],t=arguments.length<=1||void 0===arguments[1]?this.state:arguments[1],r=t.stateProps,n=t.dispatchProps,o=b(r,n,e);return j.default(v.default(o),"`mergeProps` must return an object. Instead received %s.",o),o},a.prototype.getUnderlyingRef=function(){return this.underlyingRef},a.prototype.setUnderlyingRef=function(e){this.underlyingRef=e},a.prototype.render=function(){return e.createElement(r,f({ref:this.setUnderlyingRef},this.merge()))},a}(t)}}}t.__esModule=!0;var c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=a;var p=r(1),l=n(p),d=r(7),h=n(d),y=r(6),b=n(y),m=r(5),v=n(m),g=r(8),x=n(g),_=r(9),j=n(_),P=function(){return{}},R=function(e){return{dispatch:e}},w=function(e,t,r){return f({},r,e,t)},O=0;e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,r=e.PropTypes,n=c.default(r);return function(e){function t(r,n){o(this,t),e.call(this,r,n),this.state={store:r.store}}return u(t,e),t.prototype.getChildContext=function(){return{store:this.state.store}},s(t,null,[{key:"childContextTypes",value:{store:n.isRequired},enumerable:!0},{key:"propTypes",value:{children:r.func.isRequired},enumerable:!0}]),t.prototype.componentWillReceiveProps=function(e){var t=this.state.store,r=e.store;if(t!==r){var n=r.getReducer();t.replaceReducer(n)}},t.prototype.render=function(){var e=this.props.children;return e()},t}(t)}t.__esModule=!0;var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=i;var a=r(1),c=n(a);e.exports=t.default},function(e,t){"use strict";function r(e){if(!e||"object"!=typeof e)return!1;var t="function"==typeof e.constructor?Object.getPrototypeOf(e):Object.prototype;if(null===t)return!0;var r=t.constructor;return"function"==typeof r&&r instanceof r&&n(r)===n(Object)}t.__esModule=!0,t.default=r;var n=function(e){return Function.prototype.toString.call(e)};e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++)if(!o.call(t,r[u])||e[r[u]]!==t[r[u]])return!1;return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++){if(!o.call(t,r[u]))return!1;var i=e[r[u]],s=t[r[u]];if(i!==s||"object"==typeof i||"object"==typeof s)return!1}return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return function(t){return o.bindActionCreators(e,t)}}t.__esModule=!0,t.default=n;var o=r(11);e.exports=t.default},function(e,t,r){"use strict";var n=function(e,t,r,n,o,u,i,s){if(!e){var a;if(void 0===t)a=new 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,u,i,s],f=0;a=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return c[f++]}))}throw a.framesToPop=1,a}};e.exports=n},function(t,r){t.exports=e},function(e,r){e.exports=t}])});

@@ -64,2 +64,5 @@ 'use strict';

// Helps track hot reloading.
var nextVersion = 0;
function createConnect(React) {

@@ -71,9 +74,10 @@ var Component = React.Component;

return function connect() {
var mapStateToProps = arguments.length <= 0 || arguments[0] === undefined ? defaultMapStateToProps : arguments[0];
var actionCreatorsOrMapDispatchToProps = arguments.length <= 1 || arguments[1] === undefined ? defaultMapDispatchToProps : arguments[1];
var mergeProps = arguments.length <= 2 || arguments[2] === undefined ? defaultMergeProps : arguments[2];
return function connect(mapStateToProps, mapDispatchToProps, mergeProps) {
var shouldSubscribe = Boolean(mapStateToProps);
var finalMapStateToProps = mapStateToProps || defaultMapStateToProps;
var finalMapDispatchToProps = _utilsIsPlainObject2['default'](mapDispatchToProps) ? _utilsWrapActionCreators2['default'](mapDispatchToProps) : mapDispatchToProps || defaultMapDispatchToProps;
var finalMergeProps = mergeProps || defaultMergeProps;
var shouldSubscribe = mapStateToProps !== defaultMapStateToProps;
var mapDispatchToProps = _utilsIsPlainObject2['default'](actionCreatorsOrMapDispatchToProps) ? _utilsWrapActionCreators2['default'](actionCreatorsOrMapDispatchToProps) : actionCreatorsOrMapDispatchToProps;
// Helps track hot reloading.
var version = nextVersion++;

@@ -108,2 +112,3 @@ return function (DecoratedComponent) {

_Component.call(this, props, context);
this.version = version;
this.setUnderlyingRef = this.setUnderlyingRef.bind(this);

@@ -117,4 +122,4 @@ this.state = _extends({}, this.mapState(props, context), this.mapDispatch(context));

Connect.prototype.componentDidMount = function componentDidMount() {
if (shouldSubscribe) {
Connect.prototype.trySubscribe = function trySubscribe() {
if (shouldSubscribe && !this.unsubscribe) {
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this));

@@ -124,8 +129,32 @@ }

Connect.prototype.componentWillUnmount = function componentWillUnmount() {
Connect.prototype.tryUnsubscribe = function tryUnsubscribe() {
if (this.isSubscribed()) {
this.unsubscribe();
this.unsubscribe = null;
}
};
Connect.prototype.componentDidMount = function componentDidMount() {
this.trySubscribe();
};
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
if (process.env.NODE_ENV !== 'production') {
if (this.version === version) {
return;
}
// We are hot reloading!
this.version = version;
// Update the state and bindings.
this.trySubscribe();
this.setState(_extends({}, this.mapState(), this.mapDispatch()));
}
};
Connect.prototype.componentWillUnmount = function componentWillUnmount() {
this.tryUnsubscribe();
};
Connect.prototype.handleChange = function handleChange() {

@@ -145,3 +174,3 @@ var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0];

var state = context.store.getState();
var stateProps = mapStateToProps(state);
var stateProps = finalMapStateToProps(state);

@@ -157,3 +186,3 @@ _invariant2['default'](_utilsIsPlainObject2['default'](stateProps), '`mapStateToProps` must return an object. Instead received %s.', stateProps);

var dispatchProps = mapDispatchToProps(dispatch);
var dispatchProps = finalMapDispatchToProps(dispatch);

@@ -171,3 +200,3 @@ _invariant2['default'](_utilsIsPlainObject2['default'](dispatchProps), '`mapDispatchToProps` must return an object. Instead received %s.', dispatchProps);

var merged = mergeProps(stateProps, dispatchProps, props);
var merged = finalMergeProps(stateProps, dispatchProps, props);

@@ -174,0 +203,0 @@ _invariant2['default'](_utilsIsPlainObject2['default'](merged), '`mergeProps` must return an object. Instead received %s.', merged);

{
"name": "react-redux",
"version": "0.5.1",
"version": "0.5.2",
"description": "React bindings for Redux",

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

@@ -114,9 +114,9 @@ React Redux

mapDispatchToProps
)(CounterContainer);
)(Counter);
// You can also pass an object instead of defining `mapDispatchToProps`:
// export default connect(mapStateToProps, CounterActionCreators)(CounterContainer);
// export default connect(mapStateToProps, CounterActionCreators)(Counter);
// Or you can pass `dispatch` down as a prop if you omit `mapDispatchToProps`:
// export default connect(mapStateToProps)(CounterContainer);
// export default connect(mapStateToProps)(Counter);

@@ -311,3 +311,3 @@ // See more recipes in detailed connect() examples below.

function mapDispatchToProps(dispatch) {
return { addTodo: bindActionCreators(addTodo, dispatch) };
return bindActionCreators({ addTodo }, dispatch);
}

@@ -314,0 +314,0 @@

@@ -247,3 +247,3 @@ import expect from 'expect';

it('should not subscribe to stores if mapState argument is falsy', () => {
it('should pass dispatch and avoid subscription if arguments are falsy', () => {
const store = createStore(() => ({

@@ -253,22 +253,29 @@ foo: 'bar'

@connect()
class Container extends Component {
render() {
return <div {...this.props} />;
function runCheck(...connectArgs) {
@connect(...connectArgs)
class Container extends Component {
render() {
return <div {...this.props} />;
}
}
const container = TestUtils.renderIntoDocument(
<Provider store={store}>
{() => <Container pass='through' />}
</Provider>
);
const div = TestUtils.findRenderedDOMComponentWithTag(container, 'div');
expect(div.props.dispatch).toEqual(store.dispatch);
expect(div.props.foo).toBe(undefined);
expect(div.props.pass).toEqual('through');
expect(() =>
TestUtils.findRenderedComponentWithType(container, Container)
).toNotThrow();
const decorated = TestUtils.findRenderedComponentWithType(container, Container);
expect(decorated.isSubscribed()).toBe(false);
}
const container = TestUtils.renderIntoDocument(
<Provider store={store}>
{() => <Container pass='through' />}
</Provider>
);
const div = TestUtils.findRenderedDOMComponentWithTag(container, 'div');
expect(div.props.dispatch).toEqual(store.dispatch);
expect(div.props.foo).toBe(undefined);
expect(() =>
TestUtils.findRenderedComponentWithType(container, Container)
).toNotThrow();
const decorated = TestUtils.findRenderedComponentWithType(container, Container);
expect(decorated.isSubscribed()).toNotBe(true);
runCheck();
runCheck(null, null, null);
runCheck(false, false, false);
});

@@ -440,2 +447,53 @@

it('should recalculate the state and rebind the actions on hot update', () => {
const store = createStore(() => {});
@connect(
null,
() => ({ scooby: 'doo' })
)
class ContainerBefore extends Component {
render() {
return (
<div {...this.props} />
);
}
}
@connect(
() => ({ foo: 'baz' }),
() => ({ scooby: 'foo' })
)
class ContainerAfter extends Component {
render() {
return (
<div {...this.props} />
);
}
}
let container;
TestUtils.renderIntoDocument(
<Provider store={store}>
{() => <ContainerBefore ref={instance => container = instance} />}
</Provider>
);
const div = TestUtils.findRenderedDOMComponentWithTag(container, 'div');
expect(div.props.foo).toEqual(undefined);
expect(div.props.scooby).toEqual('doo');
// Crude imitation of hot reloading that does the job
Object.keys(ContainerAfter.prototype).filter(key =>
typeof ContainerAfter.prototype[key] === 'function'
).forEach(key => {
if (key !== 'render') {
ContainerBefore.prototype[key] = ContainerAfter.prototype[key];
}
});
container.forceUpdate();
expect(div.props.foo).toEqual('baz');
expect(div.props.scooby).toEqual('foo');
});
it('should set the displayName correctly', () => {

@@ -442,0 +500,0 @@ expect(connect(state => state)(

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