react-redux
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -250,2 +250,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this)); | ||
this.handleChange(); | ||
} | ||
@@ -252,0 +253,0 @@ }; |
@@ -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: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}])}); | ||
!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)),this.handleChange())},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}])}); |
@@ -122,2 +122,3 @@ 'use strict'; | ||
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this)); | ||
this.handleChange(); | ||
} | ||
@@ -124,0 +125,0 @@ }; |
{ | ||
"name": "react-redux", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "React bindings for Redux", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -112,2 +112,28 @@ import expect from 'expect'; | ||
it('should handle dispatches before componentDidMount', () => { | ||
const store = createStore(stringBuilder); | ||
@connect(state => ({ string: state }) ) | ||
class Container extends Component { | ||
componentWillMount() { | ||
store.dispatch({ type: 'APPEND', body: 'a'}); | ||
} | ||
render() { | ||
return <div {...this.props}/>; | ||
} | ||
} | ||
const tree = TestUtils.renderIntoDocument( | ||
<Provider store={store}> | ||
{() => ( | ||
<Container /> | ||
)} | ||
</Provider> | ||
); | ||
const div = TestUtils.findRenderedDOMComponentWithTag(tree, 'div'); | ||
expect(div.props.string).toBe('a'); | ||
}); | ||
it('should handle additional prop changes in addition to slice', () => { | ||
@@ -473,2 +499,14 @@ const store = createStore(() => ({ | ||
@connect( | ||
() => ({ foo: 'bar' }), | ||
() => ({ scooby: 'boo' }) | ||
) | ||
class ContainerNext extends Component { | ||
render() { | ||
return ( | ||
<div {...this.props} /> | ||
); | ||
} | ||
} | ||
let container; | ||
@@ -484,14 +522,21 @@ TestUtils.renderIntoDocument( | ||
// 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]; | ||
} | ||
}); | ||
function imitateHotReloading(TargetClass, SourceClass) { | ||
// Crude imitation of hot reloading that does the job | ||
Object.keys(SourceClass.prototype).filter(key => | ||
typeof SourceClass.prototype[key] === 'function' | ||
).forEach(key => { | ||
if (key !== 'render') { | ||
TargetClass.prototype[key] = SourceClass.prototype[key]; | ||
} | ||
}); | ||
container.forceUpdate(); | ||
} | ||
container.forceUpdate(); | ||
imitateHotReloading(ContainerBefore, ContainerAfter); | ||
expect(div.props.foo).toEqual('baz'); | ||
expect(div.props.scooby).toEqual('foo'); | ||
imitateHotReloading(ContainerBefore, ContainerNext); | ||
expect(div.props.foo).toEqual('bar'); | ||
expect(div.props.scooby).toEqual('boo'); | ||
}); | ||
@@ -498,0 +543,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
89702
1619