Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-redux

Package Overview
Dependencies
Maintainers
2
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 5.1.0-test.1 to 6.0.0-alpha.9210282

es/components/context.js

2

dist/react-redux.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("redux")):"function"==typeof define&&define.amd?define(["exports","react","redux"],e):e(t.ReactRedux={},t.React,t.Redux)}(this,function(t,e,n){"use strict";function r(t){return function(){return t}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(t){return t};var i=o,s=function(t){};var p,u=function(t,e,n,r,o,i,p,u){if(s(e),!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=[n,r,o,i,p,u],f=0;(a=Error(e.replace(/%s/g,function(){return c[f++]}))).name="Invariant Violation"}throw a.framesToPop=1,a}},a="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",c=(function(t){t.exports=function(){function t(t,e,n,r,o,i){i!==a&&u(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e};return n.checkPropTypes=i,n.PropTypes=n,n}()}(p={exports:{}},p.exports),p.exports),f=c.shape({trySubscribe:c.func.isRequired,tryUnsubscribe:c.func.isRequired,notifyNestedSubs:c.func.isRequired,isSubscribed:c.func.isRequired}),d=c.shape({subscribe:c.func.isRequired,dispatch:c.func.isRequired,getState:c.func.isRequired}),l=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},h=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y=function(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)},v=function(t,e){var n={};for(var r in t)0>e.indexOf(r)&&Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},b=function(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 m(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"store",r=n+"Subscription",o=function(t){function o(e,r){l(this,o);var i=b(this,t.call(this,e,r));return i[n]=e.store,i}return y(o,t),o.prototype.getChildContext=function(){var t;return(t={})[n]=this[n],t[r]=null,t},o.prototype.render=function(){return e.Children.only(this.props.children)},o}(e.Component);return o.propTypes={store:d.isRequired,children:c.element.isRequired},o.childContextTypes=((t={})[n]=d.isRequired,t[r]=f,t),o}var g=m(),P={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},S={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},O=Object.defineProperty,w=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols,E=Object.getOwnPropertyDescriptor,T=Object.getPrototypeOf,U=T&&T(Object);var R=function t(e,n,r){if("string"!=typeof n){if(U){var o=T(n);o&&o!==U&&t(e,o,r)}var i=w(n);C&&(i=i.concat(C(n)));for(var s=0;i.length>s;++s){var p=i[s];if(!(P[p]||S[p]||r&&r[p])){var u=E(n,p);try{O(e,p,u)}catch(t){}}}return e}return e},_=function(t,e,n,r,o,i,s,p){if(!t){var u;if(void 0===e)u=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var a=[n,r,o,i,s,p],c=0;(u=Error(e.replace(/%s/g,function(){return a[c++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}};function N(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);null!==t&&void 0!==t&&this.setState(t)}function x(t){this.setState(function(e){var n=this.constructor.getDerivedStateFromProps(t,e);return null!==n&&void 0!==n?n:null}.bind(this))}function q(t,e){try{var n=this.props,r=this.state;this.props=t,this.state=e,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,r)}finally{this.props=n,this.state=r}}N.__suppressDeprecationWarning=!0,x.__suppressDeprecationWarning=!0,q.__suppressDeprecationWarning=!0;var D=null,M={notify:function(){}};var W=function(){function t(e,n,r){l(this,t),this.store=e,this.parentSub=n,this.onStateChange=r,this.unsubscribe=null,this.listeners=M}return t.prototype.addNestedSub=function(t){return this.trySubscribe(),this.listeners.subscribe(t)},t.prototype.notifyNestedSubs=function(){this.listeners.notify()},t.prototype.isSubscribed=function(){return!!this.unsubscribe},t.prototype.trySubscribe=function(){var t,e;this.unsubscribe||(this.unsubscribe=this.parentSub?this.parentSub.addNestedSub(this.onStateChange):this.store.subscribe(this.onStateChange),this.listeners=(t=[],e=[],{clear:function(){e=D,t=D},notify:function(){for(var n=t=e,r=0;n.length>r;r++)n[r]()},get:function(){return e},subscribe:function(n){var r=!0;return e===t&&(e=t.slice()),e.push(n),function(){r&&t!==D&&(r=!1,e===t&&(e=t.slice()),e.splice(e.indexOf(n),1))}}}))},t.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.listeners.clear(),this.listeners=M)},t}(),j=0;function F(){}function I(t){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.getDisplayName,s=void 0===i?function(t){return"ConnectAdvanced("+t+")"}:i,p=o.methodName,u=void 0===p?"connectAdvanced":p,a=o.renderCountProp,c=void 0===a?void 0:a,m=o.shouldHandleStateChanges,g=void 0===m||m,P=o.storeKey,S=void 0===P?"store":P,O=o.withRef,w=void 0!==O&&O,C=v(o,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef"]),E=S+"Subscription",T=j++,U=((n={})[S]=d,n[E]=f,n),D=((r={})[E]=f,r);function M(t,e){return e.updater(t,e)}return function(n){_("function"==typeof n,"You must pass a component to the function returned by "+u+". Instead received "+JSON.stringify(n));var r=n.displayName||n.name||"Component",o=s(r),i=h({},C,{getDisplayName:s,methodName:u,renderCountProp:c,shouldHandleStateChanges:g,storeKey:S,withRef:w,displayName:o,wrappedComponentName:r,WrappedComponent:n}),p=function(r){function s(t,e){l(this,s);var n=b(this,r.call(this,t,e));return n.version=T,n.renderCount=0,n.store=t[S]||e[S],n.propsMode=!!t[S],n.setWrappedInstance=n.setWrappedInstance.bind(n),_(n.store,'Could not find "'+S+'" in either the context or props of "'+o+'". Either wrap the root component in a <Provider>, or explicitly pass "'+S+'" as a prop to "'+o+'".'),n.state={updater:n.createUpdater()},n.initSubscription(),n}return y(s,r),s.prototype.getChildContext=function(){var t;return(t={})[E]=(this.propsMode?null:this.subscription)||this.context[E],t},s.prototype.componentDidMount=function(){g&&(this.subscription.trySubscribe(),this.runUpdater())},s.prototype.shouldComponentUpdate=function(t,e){return e.shouldComponentUpdate},s.prototype.componentWillUnmount=function(){this.subscription&&this.subscription.tryUnsubscribe(),this.subscription=null,this.notifyNestedSubs=F,this.store=null,this.isUnmounted=!0},s.prototype.getWrappedInstance=function(){return _(w,"To access the wrapped instance, you need to specify { withRef: true } in the options argument of the "+u+"() call."),this.wrappedInstance},s.prototype.setWrappedInstance=function(t){this.wrappedInstance=t},s.prototype.createUpdater=function(){return function(t,e){return function(n,r){try{var o=t(e.getState(),n);return o!==r.props||r.error?{shouldComponentUpdate:!0,props:o,error:null}:{shouldComponentUpdate:!1}}catch(t){return{shouldComponentUpdate:!0,error:t}}}}(t(this.store.dispatch,i),this.store)},s.prototype.runUpdater=function(){var t=this;this.isUnmounted||this.setState(function(e){return e.updater(t.props,e)},arguments.length>0&&void 0!==arguments[0]?arguments[0]:F)},s.prototype.initSubscription=function(){g&&(this.subscription=new W(this.store,(this.propsMode?this.props:this.context)[E],this.onStateChange.bind(this)),this.notifyNestedSubs=this.subscription.notifyNestedSubs.bind(this.subscription))},s.prototype.onStateChange=function(){this.runUpdater(this.notifyNestedSubs)},s.prototype.isSubscribed=function(){return!!this.subscription&&this.subscription.isSubscribed()},s.prototype.addExtraProps=function(t){if(!(w||c||this.propsMode&&this.subscription))return t;var e=h({},t);return w&&(e.ref=this.setWrappedInstance),c&&(e[c]=this.renderCount++),this.propsMode&&this.subscription&&(e[E]=this.subscription),e},s.prototype.render=function(){if(this.state.error)throw this.state.error;return e.createElement(n,this.addExtraProps(this.state.props))},s}(e.Component);return p.WrappedComponent=n,p.displayName=o,p.childContextTypes=D,p.contextTypes=U,p.propTypes=U,p.getDerivedStateFromProps=M,function(t){var e=t.prototype;if(!e||!e.isReactComponent)throw Error("Can only polyfill class components");if("function"!=typeof t.getDerivedStateFromProps&&"function"!=typeof e.getSnapshotBeforeUpdate)return t;var n=null,r=null,o=null;if("function"==typeof e.componentWillMount?n="componentWillMount":"function"==typeof e.UNSAFE_componentWillMount&&(n="UNSAFE_componentWillMount"),"function"==typeof e.componentWillReceiveProps?r="componentWillReceiveProps":"function"==typeof e.UNSAFE_componentWillReceiveProps&&(r="UNSAFE_componentWillReceiveProps"),"function"==typeof e.componentWillUpdate?o="componentWillUpdate":"function"==typeof e.UNSAFE_componentWillUpdate&&(o="UNSAFE_componentWillUpdate"),null!==n||null!==r||null!==o)throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+(t.displayName||t.name)+" uses "+("function"==typeof t.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()")+" but also contains the following legacy lifecycles:"+(null!==n?"\n "+n:"")+(null!==r?"\n "+r:"")+(null!==o?"\n "+o:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks");if("function"==typeof t.getDerivedStateFromProps&&(e.componentWillMount=N,e.componentWillReceiveProps=x),"function"==typeof e.getSnapshotBeforeUpdate){if("function"!=typeof e.componentDidUpdate)throw Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");e.componentWillUpdate=q;var i=e.componentDidUpdate;e.componentDidUpdate=function(t,e,n){i.call(this,t,e,this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:n)}}}(p),R(p,n)}}var A=Object.prototype.hasOwnProperty;function k(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}function B(t,e){if(k(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(var r=0;n.length>r;r++)if(!A.call(e,n[r])||!k(t[n[r]],e[n[r]]))return!1;return!0}function H(t){return function(e,n){var r=t(e,n);function o(){return r}return o.dependsOnOwnProps=!1,o}}function K(t){return null!==t.dependsOnOwnProps&&void 0!==t.dependsOnOwnProps?!!t.dependsOnOwnProps:1!==t.length}function L(t,e){return function(e,n){var r=function(t,e){return r.dependsOnOwnProps?r.mapToProps(t,e):r.mapToProps(t)};return r.dependsOnOwnProps=!0,r.mapToProps=function(e,n){r.mapToProps=t,r.dependsOnOwnProps=K(t);var o=r(e,n);return"function"==typeof o&&(r.mapToProps=o,r.dependsOnOwnProps=K(o),o=r(e,n)),o},r}}var V=[function(t){return"function"==typeof t?L(t):void 0},function(t){return t?void 0:H(function(t){return{dispatch:t}})},function(t){return t&&"object"==typeof t?H(function(e){return n.bindActionCreators(t,e)}):void 0}];var Y=[function(t){return"function"==typeof t?L(t):void 0},function(t){return t?void 0:H(function(){return{}})}];function J(t,e,n){return h({},n,t,e)}var z=[function(t){return"function"==typeof t?function(t){return function(e,n){var r=n.pure,o=n.areMergedPropsEqual,i=!1,s=void 0;return function(e,n,p){var u=t(e,n,p);return i?r&&o(u,s)||(s=u):(i=!0,s=u),s}}}(t):void 0},function(t){return t?void 0:function(){return J}}];function G(t,e,n,r){return function(o,i){return n(t(o,i),e(r,i),i)}}function Q(t,e,n,r,o){var i=o.areStatesEqual,s=o.areOwnPropsEqual,p=o.areStatePropsEqual,u=!1,a=void 0,c=void 0,f=void 0,d=void 0,l=void 0;function h(o,u){var h,y,v=!s(u,c),b=!i(o,a);return a=o,c=u,v&&b?(f=t(a,c),e.dependsOnOwnProps&&(d=e(r,c)),l=n(f,d,c)):v?(t.dependsOnOwnProps&&(f=t(a,c)),e.dependsOnOwnProps&&(d=e(r,c)),l=n(f,d,c)):b?(h=t(a,c),y=!p(h,f),f=h,y&&(l=n(f,d,c)),l):l}return function(o,i){return u?h(o,i):(f=t(a=o,c=i),d=e(r,c),l=n(f,d,c),u=!0,l)}}function X(t,e){var n=e.initMapStateToProps,r=e.initMapDispatchToProps,o=e.initMergeProps,i=v(e,["initMapStateToProps","initMapDispatchToProps","initMergeProps"]),s=n(t,i),p=r(t,i),u=o(t,i);return(i.pure?Q:G)(s,p,u,t,i)}function Z(t,e,n){for(var r=e.length-1;r>=0;r--){var o=e[r](t);if(o)return o}return function(e,r){throw Error("Invalid value of type "+typeof t+" for "+n+" argument when connecting component "+r.wrappedComponentName+".")}}function $(t,e){return t===e}var tt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.connectHOC,n=void 0===e?I:e,r=t.mapStateToPropsFactories,o=void 0===r?Y:r,i=t.mapDispatchToPropsFactories,s=void 0===i?V:i,p=t.mergePropsFactories,u=void 0===p?z:p,a=t.selectorFactory,c=void 0===a?X:a;return function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},p=i.pure,a=void 0===p||p,f=i.areStatesEqual,d=void 0===f?$:f,l=i.areOwnPropsEqual,y=void 0===l?B:l,b=i.areStatePropsEqual,m=void 0===b?B:b,g=i.areMergedPropsEqual,P=void 0===g?B:g,S=v(i,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),O=Z(t,o,"mapStateToProps"),w=Z(e,s,"mapDispatchToProps"),C=Z(r,u,"mergeProps");return n(c,h({methodName:"connect",getDisplayName:function(t){return"Connect("+t+")"},shouldHandleStateChanges:!!t,initMapStateToProps:O,initMapDispatchToProps:w,initMergeProps:C,pure:a,areStatesEqual:d,areOwnPropsEqual:y,areStatePropsEqual:m,areMergedPropsEqual:P},S))}}();t.Provider=g,t.createProvider=m,t.connectAdvanced=I,t.connect=tt,Object.defineProperty(t,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("redux")):"function"==typeof define&&define.amd?define(["exports","react","redux"],t):t(e.ReactRedux={},e.React,e.Redux)}(this,function(e,t,r){"use strict";var n="default"in t?t.default:t;function o(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return function(){return e}}var a=function(){};a.thatReturns=i,a.thatReturnsFalse=i(!1),a.thatReturnsTrue=i(!0),a.thatReturnsNull=i(null),a.thatReturnsThis=function(){return this},a.thatReturnsArgument=function(e){return e};var s=a,u=function(e){};var p=function(e,t,r,n,o,i,a,s){if(u(t),!e){var p;if(void 0===t)p=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,i,a,s],f=0;(p=Error(t.replace(/%s/g,function(){return c[f++]}))).name="Invariant Violation"}throw p.framesToPop=1,p}},c="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",f=o(function(e){e.exports=function(){function e(e,t,r,n,o,i){i!==c&&p(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=s,r.PropTypes=r,r}()}),d=f.shape({subscribe:f.func.isRequired,dispatch:f.func.isRequired,getState:f.func.isRequired}),l=n.createContext(null),h=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},v=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},m=function(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&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},y=function(e,t){var r={};for(var n in e)0>t.indexOf(n)&&Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r},P=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t};function b(){var e=function(e){function t(r){h(this,t);var n=P(this,e.call(this,r)),o=r.store;return n.state={storeState:o.getState(),store:o},n}return m(t,e),t.prototype.componentDidMount=function(){this._isMounted=!0,this.subscribe()},t.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe(),this._isMounted=!1},t.prototype.componentDidUpdate=function(e){this.props.store!==e.store&&(this.unsubscribe&&this.unsubscribe(),this.subscribe())},t.prototype.subscribe=function(){var e=this,t=this.props.store;this.unsubscribe=t.subscribe(function(){var r=t.getState();e._isMounted&&e.setState(function(e){return e.storeState===r?null:{storeState:r}})});var r=t.getState();r!==this.state.storeState&&this.setState({storeState:r})},t.prototype.render=function(){return n.createElement(this.props.contextProvider||l.Provider,{value:this.state},this.props.children)},t}(t.Component);return e.propTypes={store:d.isRequired,children:f.element.isRequired,contextProvider:f.object},e}var w=b(),O={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},g={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},S=Object.defineProperty,C=Object.getOwnPropertyNames,T=Object.getOwnPropertySymbols,x=Object.getOwnPropertyDescriptor,R=Object.getPrototypeOf,E=R&&R(Object);var j,M=function e(t,r,n){if("string"!=typeof r){if(E){var o=R(r);o&&o!==E&&e(t,o,n)}var i=C(r);T&&(i=i.concat(T(r)));for(var a=0;i.length>a;++a){var s=i[a];if(!(O[s]||g[s]||n&&n[s])){var u=x(r,s);try{S(t,s,u)}catch(e){}}}return t}return t},_=function(e,t,r,n,o,i,a,s){if(!e){var u;if(void 0===t)u=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[r,n,o,i,a,s],c=0;(u=Error(t.replace(/%s/g,function(){return p[c++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}},q=o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&Symbol.for,n=r?Symbol.for("react.element"):60103,o=r?Symbol.for("react.portal"):60106,i=r?Symbol.for("react.fragment"):60107,a=r?Symbol.for("react.strict_mode"):60108,s=r?Symbol.for("react.profiler"):60114,u=r?Symbol.for("react.provider"):60109,p=r?Symbol.for("react.context"):60110,c=r?Symbol.for("react.async_mode"):60111,f=r?Symbol.for("react.forward_ref"):60112,d=r?Symbol.for("react.timeout"):60113;function l(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case c:case i:case s:case a:return e;default:switch(e=e&&e.$$typeof){case p:case f:case u:return e;default:return t}}case o:return t}}}t.typeOf=l,t.AsyncMode=c,t.ContextConsumer=p,t.ContextProvider=u,t.Element=n,t.ForwardRef=f,t.Fragment=i,t.Profiler=s,t.Portal=o,t.StrictMode=a,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===c||e===s||e===a||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===u||e.$$typeof===p||e.$$typeof===f)},t.isAsyncMode=function(e){return l(e)===c},t.isContextConsumer=function(e){return l(e)===p},t.isContextProvider=function(e){return l(e)===u},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return l(e)===f},t.isFragment=function(e){return l(e)===i},t.isProfiler=function(e){return l(e)===s},t.isPortal=function(e){return l(e)===o},t.isStrictMode=function(e){return l(e)===a}});(j=q)&&j.__esModule&&Object.prototype.hasOwnProperty.call(j,"default");var N=o(function(e){e.exports=q}).isValidElementType,D=0;function F(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.getDisplayName,i=void 0===o?function(e){return"ConnectAdvanced("+e+")"}:o,a=r.methodName,s=void 0===a?"connectAdvanced":a,u=r.shouldHandleStateChanges,p=void 0===u||u,c=r.consumer,b=void 0===c?l.Consumer:c,w=r.storeKey,O=void 0===w?"store":w,g=r.withRef,S=void 0!==g&&g,C=r.forwardRef,T=void 0!==C&&C,x=y(r,["getDisplayName","methodName","shouldHandleStateChanges","consumer","storeKey","withRef","forwardRef"]);_(!S,"withRef is removed. To access the wrapped instance, use a ref on the connected component"),_("store"===O,"storeKey has been removed. To use a custom redux store for a single component, create a custom React context with React.createContext() and pass the Provider to react-redux's provider and the Consumer to this component as in <Provider context={context.Provider}><ConnectedComponent consumer={context.Consumer} /></Provider>");var R=D++;return function(r){_(N(r),"You must pass a component to the function returned by "+s+". Instead received "+JSON.stringify(r));var o=r.displayName||r.name||"Component",a=i(o),u=v({},x,{getDisplayName:i,methodName:s,shouldHandleStateChanges:p,displayName:a,wrappedComponentName:o,WrappedComponent:r}),c=x.pure?t.PureComponent:t.Component;function l(t){return e(t.dispatch,u)}var w=function(e){function t(r){h(this,t);var n=P(this,e.call(this,r));return n.state={wrapperProps:r.wrapperProps,store:r.store,error:null,childPropsSelector:l(r.store),childProps:{}},n.state=v({},n.state,t.getChildPropsState(r,n.state)),n}return m(t,e),t.getChildPropsState=function(e,t){try{var r=t.childPropsSelector;e.store!==t.store&&(r=l(e.store));var n=r(e.storeState,e.wrapperProps);return n===t.childProps?null:{childProps:n,store:e.store,childPropsSelector:r}}catch(e){return{error:e}}},t.getDerivedStateFromProps=function(e,r){var n=t.getChildPropsState(e,r);return null===n?null:v({},n,{wrapperProps:e.wrapperProps})},t.prototype.shouldComponentUpdate=function(e,t){return t.childProps!==this.state.childProps||!!t.error},t.prototype.render=function(){if(this.state.error)throw this.state.error;return n.createElement(r,v({},this.state.childProps,{ref:this.props.forwardRef}))},t}(t.Component);w.propTypes={wrapperProps:f.object,store:d};var O=function(e){function t(r){h(this,t);var n,o=P(this,e.call(this,r));return o.version=R,o.renderInner=o.renderInner.bind(o),o.wrapperPropsMemoizer=(n=void 0,function(e){if(void 0===e)return n;var t=e.contextConsumer,r=e.forwardRef,o=y(e,["contextConsumer","forwardRef"]);return n={contextConsumer:t,forwardRef:r,wrapperProps:o}}),o}return m(t,e),t.prototype.renderInner=function(e){var t=e.storeState,r=e.store,o=this.wrapperPropsMemoizer(this.props);return n.createElement(w,{key:this.version,storeState:t,store:r,wrapperProps:o.wrapperProps,forwardRef:o.forwardRef})},t.prototype.render=function(){return n.createElement(this.props.contextConsumer||b,null,this.renderInner)},t}(c);O.WrappedComponent=r,O.displayName=a,O.propTypes={contextConsumer:f.object,forwardRef:f.oneOfType([f.func,f.object])};var g=O;T&&(g=n.forwardRef(function(e,t){return n.createElement(O,v({},e,{forwardRef:t}))}));return M(g,r)}}var $=Object.prototype.hasOwnProperty;function I(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function A(e,t){if(I(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(var n=0;r.length>n;n++)if(!$.call(t,r[n])||!I(e[r[n]],t[r[n]]))return!1;return!0}function k(e){return function(t,r){var n=e(t,r);function o(){return n}return o.dependsOnOwnProps=!1,o}}function H(e){return null!==e.dependsOnOwnProps&&void 0!==e.dependsOnOwnProps?!!e.dependsOnOwnProps:1!==e.length}function U(e,t){return function(t,r){var n=function(e,t){return n.dependsOnOwnProps?n.mapToProps(e,t):n.mapToProps(e)};return n.dependsOnOwnProps=!0,n.mapToProps=function(t,r){n.mapToProps=e,n.dependsOnOwnProps=H(e);var o=n(t,r);return"function"==typeof o&&(n.mapToProps=o,n.dependsOnOwnProps=H(o),o=n(t,r)),o},n}}var V=[function(e){return"function"==typeof e?U(e):void 0},function(e){return e?void 0:k(function(e){return{dispatch:e}})},function(e){return e&&"object"==typeof e?k(function(t){return r.bindActionCreators(e,t)}):void 0}];var W=[function(e){return"function"==typeof e?U(e):void 0},function(e){return e?void 0:k(function(){return{}})}];function K(e,t,r){return v({},r,e,t)}var z=[function(e){return"function"==typeof e?function(e){return function(t,r){var n=r.pure,o=r.areMergedPropsEqual,i=!1,a=void 0;return function(t,r,s){var u=e(t,r,s);return i?n&&o(u,a)||(a=u):(i=!0,a=u),a}}}(e):void 0},function(e){return e?void 0:function(){return K}}];function L(e,t,r,n){return function(o,i){return r(e(o,i),t(n,i),i)}}function Y(e,t,r,n,o){var i=o.areStatesEqual,a=o.areOwnPropsEqual,s=o.areStatePropsEqual,u=!1,p=void 0,c=void 0,f=void 0,d=void 0,l=void 0;function h(o,u){var h,v,m=!a(u,c),y=!i(o,p);return p=o,c=u,m&&y?(f=e(p,c),t.dependsOnOwnProps&&(d=t(n,c)),l=r(f,d,c)):m?(e.dependsOnOwnProps&&(f=e(p,c)),t.dependsOnOwnProps&&(d=t(n,c)),l=r(f,d,c)):y?(h=e(p,c),v=!s(h,f),f=h,v&&(l=r(f,d,c)),l):l}return function(o,i){return u?h(o,i):(f=e(p=o,c=i),d=t(n,c),l=r(f,d,c),u=!0,l)}}function B(e,t){var r=t.initMapStateToProps,n=t.initMapDispatchToProps,o=t.initMergeProps,i=y(t,["initMapStateToProps","initMapDispatchToProps","initMergeProps"]),a=r(e,i),s=n(e,i),u=o(e,i);return(i.pure?Y:L)(a,s,u,e,i)}function J(e,t,r){for(var n=t.length-1;n>=0;n--){var o=t[n](e);if(o)return o}return function(t,n){throw Error("Invalid value of type "+typeof e+" for "+r+" argument when connecting component "+n.wrappedComponentName+".")}}function G(e,t){return e===t}var Q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.connectHOC,r=void 0===t?F:t,n=e.mapStateToPropsFactories,o=void 0===n?W:n,i=e.mapDispatchToPropsFactories,a=void 0===i?V:i,s=e.mergePropsFactories,u=void 0===s?z:s,p=e.selectorFactory,c=void 0===p?B:p;return function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=i.pure,p=void 0===s||s,f=i.areStatesEqual,d=void 0===f?G:f,l=i.areOwnPropsEqual,h=void 0===l?A:l,m=i.areStatePropsEqual,P=void 0===m?A:m,b=i.areMergedPropsEqual,w=void 0===b?A:b,O=y(i,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),g=J(e,o,"mapStateToProps"),S=J(t,a,"mapDispatchToProps"),C=J(n,u,"mergeProps");return r(c,v({methodName:"connect",getDisplayName:function(e){return"Connect("+e+")"},shouldHandleStateChanges:!!e,initMapStateToProps:g,initMapDispatchToProps:S,initMergeProps:C,pure:p,areStatesEqual:d,areOwnPropsEqual:h,areStatePropsEqual:P,areMergedPropsEqual:w},O))}}();e.Provider=w,e.createProvider=b,e.connectAdvanced=F,e.connect=Q,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -13,32 +13,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

import invariant from 'invariant';
import { Component, createElement } from 'react';
import { polyfill } from 'react-lifecycles-compat';
import PropTypes from 'prop-types';
import React, { Component, PureComponent } from 'react';
import { isValidElementType } from 'react-is';
import Subscription from '../utils/Subscription';
import { storeShape, subscriptionShape } from '../utils/PropTypes';
import { ReactReduxContext } from "./context";
import { storeShape } from "../utils/PropTypes";
var hotReloadingVersion = 0;
function noop() {}
function makeUpdater(sourceSelector, store) {
return function updater(props, prevState) {
try {
var nextProps = sourceSelector(store.getState(), props);
if (nextProps !== prevState.props || prevState.error) {
return {
shouldComponentUpdate: true,
props: nextProps,
error: null
};
}
return {
shouldComponentUpdate: false
};
} catch (error) {
return {
shouldComponentUpdate: true,
error: error
};
}
};
}

@@ -61,4 +39,2 @@ export default function connectAdvanced(

selectorFactory) {
var _contextTypes, _childContextTypes;
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},

@@ -71,6 +47,6 @@ _ref$getDisplayName = _ref.getDisplayName,

methodName = _ref$methodName === undefined ? 'connectAdvanced' : _ref$methodName,
_ref$renderCountProp = _ref.renderCountProp,
renderCountProp = _ref$renderCountProp === undefined ? undefined : _ref$renderCountProp,
_ref$shouldHandleStat = _ref.shouldHandleStateChanges,
shouldHandleStateChanges = _ref$shouldHandleStat === undefined ? true : _ref$shouldHandleStat,
_ref$consumer = _ref.consumer,
consumer = _ref$consumer === undefined ? ReactReduxContext.Consumer : _ref$consumer,
_ref$storeKey = _ref.storeKey,

@@ -80,16 +56,14 @@ storeKey = _ref$storeKey === undefined ? 'store' : _ref$storeKey,

withRef = _ref$withRef === undefined ? false : _ref$withRef,
connectOptions = _objectWithoutProperties(_ref, ['getDisplayName', 'methodName', 'renderCountProp', 'shouldHandleStateChanges', 'storeKey', 'withRef']);
_ref$forwardRef = _ref.forwardRef,
forwardRef = _ref$forwardRef === undefined ? false : _ref$forwardRef,
connectOptions = _objectWithoutProperties(_ref, ['getDisplayName', 'methodName', 'shouldHandleStateChanges', 'consumer', 'storeKey', 'withRef', 'forwardRef']);
var subscriptionKey = storeKey + 'Subscription';
var version = hotReloadingVersion++;
invariant(!withRef, "withRef is removed. To access the wrapped instance, use a ref on the connected component");
var contextTypes = (_contextTypes = {}, _contextTypes[storeKey] = storeShape, _contextTypes[subscriptionKey] = subscriptionShape, _contextTypes);
var childContextTypes = (_childContextTypes = {}, _childContextTypes[subscriptionKey] = subscriptionShape, _childContextTypes);
invariant(storeKey === 'store', 'storeKey has been removed. To use a custom redux store for a single component, ' + 'create a custom React context with React.createContext() and pass the Provider to react-redux\'s provider ' + 'and the Consumer to this component as in <Provider context={context.Provider}><' + 'ConnectedComponent consumer={context.Consumer} /></Provider>');
function getDerivedStateFromProps(nextProps, prevState) {
return prevState.updater(nextProps, prevState);
}
var version = hotReloadingVersion++;
return function wrapWithConnect(WrappedComponent) {
invariant(typeof WrappedComponent == 'function', 'You must pass a component to the function returned by ' + (methodName + '. Instead received ' + JSON.stringify(WrappedComponent)));
invariant(isValidElementType(WrappedComponent), 'You must pass a component to the function returned by ' + (methodName + '. Instead received ' + JSON.stringify(WrappedComponent)));

@@ -103,6 +77,3 @@ var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';

methodName: methodName,
renderCountProp: renderCountProp,
shouldHandleStateChanges: shouldHandleStateChanges,
storeKey: storeKey,
withRef: withRef,
displayName: displayName,

@@ -113,183 +84,167 @@ wrappedComponentName: wrappedComponentName,

var Connect = function (_Component) {
_inherits(Connect, _Component);
var OuterBaseComponent = connectOptions.pure ? PureComponent : Component;
function Connect(props, context) {
_classCallCheck(this, Connect);
function createChildSelector(store) {
return selectorFactory(store.dispatch, selectorFactoryOptions);
}
var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
var ConnectInner = function (_Component) {
_inherits(ConnectInner, _Component);
_this.version = version;
_this.renderCount = 0;
_this.store = props[storeKey] || context[storeKey];
_this.propsMode = Boolean(props[storeKey]);
_this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
function ConnectInner(props) {
_classCallCheck(this, ConnectInner);
invariant(_this.store, 'Could not find "' + storeKey + '" in either the context or props of ' + ('"' + displayName + '". Either wrap the root component in a <Provider>, ') + ('or explicitly pass "' + storeKey + '" as a prop to "' + displayName + '".'));
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
_this.state = {
updater: _this.createUpdater()
wrapperProps: props.wrapperProps,
store: props.store,
error: null,
childPropsSelector: createChildSelector(props.store),
childProps: {}
};
_this.initSubscription();
_this.state = _extends({}, _this.state, ConnectInner.getChildPropsState(props, _this.state));
return _this;
}
Connect.prototype.getChildContext = function getChildContext() {
var _ref2;
ConnectInner.getChildPropsState = function getChildPropsState(props, state) {
try {
var childPropsSelector = state.childPropsSelector;
// If this component received store from props, its subscription should be transparent
// to any descendants receiving store+subscription from context; it passes along
// subscription passed to it. Otherwise, it shadows the parent subscription, which allows
// Connect to control ordering of notifications to flow top-down.
var subscription = this.propsMode ? null : this.subscription;
return _ref2 = {}, _ref2[subscriptionKey] = subscription || this.context[subscriptionKey], _ref2;
};
Connect.prototype.componentDidMount = function componentDidMount() {
if (!shouldHandleStateChanges) return;
if (props.store !== state.store) {
childPropsSelector = createChildSelector(props.store);
}
// componentWillMount fires during server side rendering, but componentDidMount and
// componentWillUnmount do not. Because of this, trySubscribe happens during ...didMount.
// Otherwise, unsubscription would never take place during SSR, causing a memory leak.
// To handle the case where a child component may have triggered a state change by
// dispatching an action in its componentWillMount, we have to re-run the select and maybe
// re-render.
this.subscription.trySubscribe();
this.runUpdater();
};
var nextProps = childPropsSelector(props.storeState, props.wrapperProps);
if (nextProps === state.childProps) return null;
Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate(_, nextState) {
return nextState.shouldComponentUpdate;
return { childProps: nextProps, store: props.store, childPropsSelector: childPropsSelector };
} catch (error) {
return { error: error };
}
};
Connect.prototype.componentWillUnmount = function componentWillUnmount() {
if (this.subscription) this.subscription.tryUnsubscribe();
this.subscription = null;
this.notifyNestedSubs = noop;
this.store = null;
this.isUnmounted = true;
};
ConnectInner.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
var nextChildProps = ConnectInner.getChildPropsState(props, state);
Connect.prototype.getWrappedInstance = function getWrappedInstance() {
invariant(withRef, 'To access the wrapped instance, you need to specify ' + ('{ withRef: true } in the options argument of the ' + methodName + '() call.'));
return this.wrappedInstance;
if (nextChildProps === null) {
return null;
}
return _extends({}, nextChildProps, {
wrapperProps: props.wrapperProps
});
};
Connect.prototype.setWrappedInstance = function setWrappedInstance(ref) {
this.wrappedInstance = ref;
ConnectInner.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
var childPropsChanged = nextState.childProps !== this.state.childProps;
var hasError = !!nextState.error;
return childPropsChanged || hasError;
};
Connect.prototype.createUpdater = function createUpdater() {
var sourceSelector = selectorFactory(this.store.dispatch, selectorFactoryOptions);
return makeUpdater(sourceSelector, this.store);
ConnectInner.prototype.render = function render() {
if (this.state.error) {
throw this.state.error;
}
return React.createElement(WrappedComponent, _extends({}, this.state.childProps, { ref: this.props.forwardRef }));
};
Connect.prototype.runUpdater = function runUpdater() {
var _this2 = this;
return ConnectInner;
}(Component);
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;
ConnectInner.propTypes = {
wrapperProps: PropTypes.object,
store: storeShape
};
if (this.isUnmounted) {
return;
function createWrapperPropsMemoizer() {
var result = void 0,
prevProps = void 0;
return function wrapperPropsMemoizer(props) {
if (props === prevProps) {
return result;
}
this.setState(function (prevState) {
return prevState.updater(_this2.props, prevState);
}, callback);
var contextConsumer = props.contextConsumer,
forwardRef = props.forwardRef,
wrapperProps = _objectWithoutProperties(props, ['contextConsumer', 'forwardRef']);
result = { contextConsumer: contextConsumer, forwardRef: forwardRef, wrapperProps: wrapperProps };
return result;
};
}
Connect.prototype.initSubscription = function initSubscription() {
if (!shouldHandleStateChanges) return;
var Connect = function (_OuterBaseComponent) {
_inherits(Connect, _OuterBaseComponent);
// parentSub's source should match where store came from: props vs. context. A component
// connected to the store via props shouldn't use subscription from context, or vice versa.
var parentSub = (this.propsMode ? this.props : this.context)[subscriptionKey];
this.subscription = new Subscription(this.store, parentSub, this.onStateChange.bind(this));
function Connect(props) {
_classCallCheck(this, Connect);
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
// the middle of the notification loop, where `this.subscription` will then be null. An
// extra null check every change can be avoided by copying the method onto `this` and then
// replacing it with a no-op on unmount. This can probably be avoided if Subscription's
// listeners logic is changed to not call listeners that have been unsubscribed in the
// middle of the notification loop.
this.notifyNestedSubs = this.subscription.notifyNestedSubs.bind(this.subscription);
};
var _this2 = _possibleConstructorReturn(this, _OuterBaseComponent.call(this, props));
Connect.prototype.onStateChange = function onStateChange() {
this.runUpdater(this.notifyNestedSubs);
};
_this2.version = version;
Connect.prototype.isSubscribed = function isSubscribed() {
return Boolean(this.subscription) && this.subscription.isSubscribed();
};
_this2.renderInner = _this2.renderInner.bind(_this2);
Connect.prototype.addExtraProps = function addExtraProps(props) {
if (!withRef && !renderCountProp && !(this.propsMode && this.subscription)) return props;
// make a shallow copy so that fields added don't leak to the original selector.
// this is especially important for 'ref' since that's a reference back to the component
// instance. a singleton memoized selector would then be holding a reference to the
// instance, preventing the instance from being garbage collected, and that would be bad
var withExtras = _extends({}, props);
if (withRef) withExtras.ref = this.setWrappedInstance;
if (renderCountProp) withExtras[renderCountProp] = this.renderCount++;
if (this.propsMode && this.subscription) withExtras[subscriptionKey] = this.subscription;
return withExtras;
_this2.wrapperPropsMemoizer = createWrapperPropsMemoizer();
return _this2;
}
Connect.prototype.renderInner = function renderInner(providerValue) {
var storeState = providerValue.storeState,
store = providerValue.store;
var _wrapperPropsMemoizer = this.wrapperPropsMemoizer(this.props),
forwardRef = _wrapperPropsMemoizer.forwardRef,
wrapperProps = _wrapperPropsMemoizer.wrapperProps;
return React.createElement(ConnectInner, {
key: this.version,
storeState: storeState,
store: store,
wrapperProps: wrapperProps,
forwardRef: forwardRef
});
};
Connect.prototype.render = function render() {
if (this.state.error) {
throw this.state.error;
} else {
return createElement(WrappedComponent, this.addExtraProps(this.state.props));
}
var ContextConsumer = this.props.contextConsumer || consumer;
return React.createElement(
ContextConsumer,
null,
this.renderInner
);
};
return Connect;
}(Component);
}(OuterBaseComponent);
Connect.WrappedComponent = WrappedComponent;
Connect.displayName = displayName;
Connect.childContextTypes = childContextTypes;
Connect.contextTypes = contextTypes;
Connect.propTypes = contextTypes;
Connect.getDerivedStateFromProps = getDerivedStateFromProps;
Connect.propTypes = {
contextConsumer: PropTypes.object,
forwardRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentDidUpdate = function componentDidUpdate() {
var _this3 = this;
// TODO We're losing the ability to add a store as a prop. Not sure there's anything we can do about that.
// We are hot reloading!
if (this.version !== version) {
this.version = version;
// If any connected descendants don't hot reload (and resubscribe in the process), their
// listeners will be lost when we unsubscribe. Unfortunately, by copying over all
// listeners, this does mean that the old versions of connected descendants will still be
// notified of state changes; however, their onStateChange function is a no-op so this
// isn't a huge deal.
var oldListeners = [];
};var wrapperComponent = Connect;
if (this.subscription) {
oldListeners = this.subscription.listeners.get();
this.subscription.tryUnsubscribe();
}
this.initSubscription();
if (shouldHandleStateChanges) {
this.subscription.trySubscribe();
oldListeners.forEach(function (listener) {
return _this3.subscription.listeners.subscribe(listener);
});
}
if (forwardRef) {
var forwarded = React.forwardRef(function (props, ref) {
return React.createElement(Connect, _extends({}, props, { forwardRef: ref }));
});
var updater = this.createUpdater();
this.setState({ updater: updater });
this.runUpdater();
}
};
wrapperComponent = forwarded;
}
polyfill(Connect);
return hoistStatics(Connect, WrappedComponent);
return hoistStatics(wrapperComponent, WrappedComponent);
};
}

@@ -7,7 +7,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

import { Component, Children } from 'react';
import React, { Component, Children } from 'react';
import PropTypes from 'prop-types';
import { storeShape, subscriptionShape } from '../utils/PropTypes';
import { storeShape } from '../utils/PropTypes';
import warning from '../utils/warning';
import { ReactReduxContext } from "./context";
var didWarnAboutReceivingStore = false;

@@ -24,28 +26,77 @@ function warnAboutReceivingStore() {

export function createProvider() {
var _Provider$childContex;
var storeKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'store';
var subscriptionKey = storeKey + 'Subscription';
var Provider = function (_Component) {
_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
var _ref;
function Provider(props) {
_classCallCheck(this, Provider);
return _ref = {}, _ref[storeKey] = this[storeKey], _ref[subscriptionKey] = null, _ref;
};
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
function Provider(props, context) {
_classCallCheck(this, Provider);
var store = props.store;
var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
_this[storeKey] = props.store;
_this.state = {
storeState: store.getState(),
store: store
};
return _this;
}
Provider.prototype.componentDidMount = function componentDidMount() {
this._isMounted = true;
this.subscribe();
};
Provider.prototype.componentWillUnmount = function componentWillUnmount() {
if (this.unsubscribe) this.unsubscribe();
this._isMounted = false;
};
Provider.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
if (this.props.store !== prevProps.store) {
if (this.unsubscribe) this.unsubscribe();
this.subscribe();
}
};
Provider.prototype.subscribe = function subscribe() {
var _this2 = this;
var store = this.props.store;
this.unsubscribe = store.subscribe(function () {
var newStoreState = store.getState();
if (!_this2._isMounted) {
return;
}
_this2.setState(function (providerState) {
// If the value is the same, skip the unnecessary state update.
if (providerState.storeState === newStoreState) {
return null;
}
return { storeState: newStoreState };
});
});
// Actions might have been dispatched between render and mount - handle those
var postMountStoreState = store.getState();
if (postMountStoreState !== this.state.storeState) {
this.setState({ storeState: postMountStoreState });
}
};
Provider.prototype.render = function render() {
return Children.only(this.props.children);
var ContextProvider = this.props.contextProvider || ReactReduxContext.Provider;
return React.createElement(
ContextProvider,
{ value: this.state },
this.props.children
);
};

@@ -56,15 +107,7 @@

if (process.env.NODE_ENV !== 'production') {
Provider.prototype.componentDidUpdate = function () {
if (this[storeKey] !== this.props.store) {
warnAboutReceivingStore();
}
};
}
Provider.propTypes = {
store: storeShape.isRequired,
children: PropTypes.element.isRequired
children: PropTypes.element.isRequired,
contextProvider: PropTypes.object
};
Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[storeKey] = storeShape.isRequired, _Provider$childContex[subscriptionKey] = subscriptionShape, _Provider$childContex);

@@ -71,0 +114,0 @@ return Provider;

import PropTypes from 'prop-types';
export var subscriptionShape = PropTypes.shape({
trySubscribe: PropTypes.func.isRequired,
tryUnsubscribe: PropTypes.func.isRequired,
notifyNestedSubs: PropTypes.func.isRequired,
isSubscribed: PropTypes.func.isRequired
});
export var storeShape = PropTypes.shape({

@@ -11,0 +4,0 @@ subscribe: PropTypes.func.isRequired,

@@ -17,9 +17,13 @@ 'use strict';

var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _react = require('react');
var _reactLifecyclesCompat = require('react-lifecycles-compat');
var _react2 = _interopRequireDefault(_react);
var _Subscription = require('../utils/Subscription');
var _reactIs = require('react-is');
var _Subscription2 = _interopRequireDefault(_Subscription);
var _context = require('./context');

@@ -39,25 +43,2 @@ var _PropTypes = require('../utils/PropTypes');

var hotReloadingVersion = 0;
function noop() {}
function makeUpdater(sourceSelector, store) {
return function updater(props, prevState) {
try {
var nextProps = sourceSelector(store.getState(), props);
if (nextProps !== prevState.props || prevState.error) {
return {
shouldComponentUpdate: true,
props: nextProps,
error: null
};
}
return {
shouldComponentUpdate: false
};
} catch (error) {
return {
shouldComponentUpdate: true,
error: error
};
}
};
}

@@ -80,4 +61,2 @@ function connectAdvanced(

selectorFactory) {
var _contextTypes, _childContextTypes;
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},

@@ -90,6 +69,6 @@ _ref$getDisplayName = _ref.getDisplayName,

methodName = _ref$methodName === undefined ? 'connectAdvanced' : _ref$methodName,
_ref$renderCountProp = _ref.renderCountProp,
renderCountProp = _ref$renderCountProp === undefined ? undefined : _ref$renderCountProp,
_ref$shouldHandleStat = _ref.shouldHandleStateChanges,
shouldHandleStateChanges = _ref$shouldHandleStat === undefined ? true : _ref$shouldHandleStat,
_ref$consumer = _ref.consumer,
consumer = _ref$consumer === undefined ? _context.ReactReduxContext.Consumer : _ref$consumer,
_ref$storeKey = _ref.storeKey,

@@ -99,16 +78,14 @@ storeKey = _ref$storeKey === undefined ? 'store' : _ref$storeKey,

withRef = _ref$withRef === undefined ? false : _ref$withRef,
connectOptions = _objectWithoutProperties(_ref, ['getDisplayName', 'methodName', 'renderCountProp', 'shouldHandleStateChanges', 'storeKey', 'withRef']);
_ref$forwardRef = _ref.forwardRef,
forwardRef = _ref$forwardRef === undefined ? false : _ref$forwardRef,
connectOptions = _objectWithoutProperties(_ref, ['getDisplayName', 'methodName', 'shouldHandleStateChanges', 'consumer', 'storeKey', 'withRef', 'forwardRef']);
var subscriptionKey = storeKey + 'Subscription';
var version = hotReloadingVersion++;
(0, _invariant2.default)(!withRef, "withRef is removed. To access the wrapped instance, use a ref on the connected component");
var contextTypes = (_contextTypes = {}, _contextTypes[storeKey] = _PropTypes.storeShape, _contextTypes[subscriptionKey] = _PropTypes.subscriptionShape, _contextTypes);
var childContextTypes = (_childContextTypes = {}, _childContextTypes[subscriptionKey] = _PropTypes.subscriptionShape, _childContextTypes);
(0, _invariant2.default)(storeKey === 'store', 'storeKey has been removed. To use a custom redux store for a single component, ' + 'create a custom React context with React.createContext() and pass the Provider to react-redux\'s provider ' + 'and the Consumer to this component as in <Provider context={context.Provider}><' + 'ConnectedComponent consumer={context.Consumer} /></Provider>');
function getDerivedStateFromProps(nextProps, prevState) {
return prevState.updater(nextProps, prevState);
}
var version = hotReloadingVersion++;
return function wrapWithConnect(WrappedComponent) {
(0, _invariant2.default)(typeof WrappedComponent == 'function', 'You must pass a component to the function returned by ' + (methodName + '. Instead received ' + JSON.stringify(WrappedComponent)));
(0, _invariant2.default)((0, _reactIs.isValidElementType)(WrappedComponent), 'You must pass a component to the function returned by ' + (methodName + '. Instead received ' + JSON.stringify(WrappedComponent)));

@@ -122,6 +99,3 @@ var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';

methodName: methodName,
renderCountProp: renderCountProp,
shouldHandleStateChanges: shouldHandleStateChanges,
storeKey: storeKey,
withRef: withRef,
displayName: displayName,

@@ -132,183 +106,167 @@ wrappedComponentName: wrappedComponentName,

var Connect = function (_Component) {
_inherits(Connect, _Component);
var OuterBaseComponent = connectOptions.pure ? _react.PureComponent : _react.Component;
function Connect(props, context) {
_classCallCheck(this, Connect);
function createChildSelector(store) {
return selectorFactory(store.dispatch, selectorFactoryOptions);
}
var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
var ConnectInner = function (_Component) {
_inherits(ConnectInner, _Component);
_this.version = version;
_this.renderCount = 0;
_this.store = props[storeKey] || context[storeKey];
_this.propsMode = Boolean(props[storeKey]);
_this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
function ConnectInner(props) {
_classCallCheck(this, ConnectInner);
(0, _invariant2.default)(_this.store, 'Could not find "' + storeKey + '" in either the context or props of ' + ('"' + displayName + '". Either wrap the root component in a <Provider>, ') + ('or explicitly pass "' + storeKey + '" as a prop to "' + displayName + '".'));
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
_this.state = {
updater: _this.createUpdater()
wrapperProps: props.wrapperProps,
store: props.store,
error: null,
childPropsSelector: createChildSelector(props.store),
childProps: {}
};
_this.initSubscription();
_this.state = _extends({}, _this.state, ConnectInner.getChildPropsState(props, _this.state));
return _this;
}
Connect.prototype.getChildContext = function getChildContext() {
var _ref2;
ConnectInner.getChildPropsState = function getChildPropsState(props, state) {
try {
var childPropsSelector = state.childPropsSelector;
// If this component received store from props, its subscription should be transparent
// to any descendants receiving store+subscription from context; it passes along
// subscription passed to it. Otherwise, it shadows the parent subscription, which allows
// Connect to control ordering of notifications to flow top-down.
var subscription = this.propsMode ? null : this.subscription;
return _ref2 = {}, _ref2[subscriptionKey] = subscription || this.context[subscriptionKey], _ref2;
};
Connect.prototype.componentDidMount = function componentDidMount() {
if (!shouldHandleStateChanges) return;
if (props.store !== state.store) {
childPropsSelector = createChildSelector(props.store);
}
// componentWillMount fires during server side rendering, but componentDidMount and
// componentWillUnmount do not. Because of this, trySubscribe happens during ...didMount.
// Otherwise, unsubscription would never take place during SSR, causing a memory leak.
// To handle the case where a child component may have triggered a state change by
// dispatching an action in its componentWillMount, we have to re-run the select and maybe
// re-render.
this.subscription.trySubscribe();
this.runUpdater();
};
var nextProps = childPropsSelector(props.storeState, props.wrapperProps);
if (nextProps === state.childProps) return null;
Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate(_, nextState) {
return nextState.shouldComponentUpdate;
return { childProps: nextProps, store: props.store, childPropsSelector: childPropsSelector };
} catch (error) {
return { error: error };
}
};
Connect.prototype.componentWillUnmount = function componentWillUnmount() {
if (this.subscription) this.subscription.tryUnsubscribe();
this.subscription = null;
this.notifyNestedSubs = noop;
this.store = null;
this.isUnmounted = true;
};
ConnectInner.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
var nextChildProps = ConnectInner.getChildPropsState(props, state);
Connect.prototype.getWrappedInstance = function getWrappedInstance() {
(0, _invariant2.default)(withRef, 'To access the wrapped instance, you need to specify ' + ('{ withRef: true } in the options argument of the ' + methodName + '() call.'));
return this.wrappedInstance;
if (nextChildProps === null) {
return null;
}
return _extends({}, nextChildProps, {
wrapperProps: props.wrapperProps
});
};
Connect.prototype.setWrappedInstance = function setWrappedInstance(ref) {
this.wrappedInstance = ref;
ConnectInner.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
var childPropsChanged = nextState.childProps !== this.state.childProps;
var hasError = !!nextState.error;
return childPropsChanged || hasError;
};
Connect.prototype.createUpdater = function createUpdater() {
var sourceSelector = selectorFactory(this.store.dispatch, selectorFactoryOptions);
return makeUpdater(sourceSelector, this.store);
ConnectInner.prototype.render = function render() {
if (this.state.error) {
throw this.state.error;
}
return _react2.default.createElement(WrappedComponent, _extends({}, this.state.childProps, { ref: this.props.forwardRef }));
};
Connect.prototype.runUpdater = function runUpdater() {
var _this2 = this;
return ConnectInner;
}(_react.Component);
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;
ConnectInner.propTypes = {
wrapperProps: _propTypes2.default.object,
store: _PropTypes.storeShape
};
if (this.isUnmounted) {
return;
function createWrapperPropsMemoizer() {
var result = void 0,
prevProps = void 0;
return function wrapperPropsMemoizer(props) {
if (props === prevProps) {
return result;
}
this.setState(function (prevState) {
return prevState.updater(_this2.props, prevState);
}, callback);
var contextConsumer = props.contextConsumer,
forwardRef = props.forwardRef,
wrapperProps = _objectWithoutProperties(props, ['contextConsumer', 'forwardRef']);
result = { contextConsumer: contextConsumer, forwardRef: forwardRef, wrapperProps: wrapperProps };
return result;
};
}
Connect.prototype.initSubscription = function initSubscription() {
if (!shouldHandleStateChanges) return;
var Connect = function (_OuterBaseComponent) {
_inherits(Connect, _OuterBaseComponent);
// parentSub's source should match where store came from: props vs. context. A component
// connected to the store via props shouldn't use subscription from context, or vice versa.
var parentSub = (this.propsMode ? this.props : this.context)[subscriptionKey];
this.subscription = new _Subscription2.default(this.store, parentSub, this.onStateChange.bind(this));
function Connect(props) {
_classCallCheck(this, Connect);
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
// the middle of the notification loop, where `this.subscription` will then be null. An
// extra null check every change can be avoided by copying the method onto `this` and then
// replacing it with a no-op on unmount. This can probably be avoided if Subscription's
// listeners logic is changed to not call listeners that have been unsubscribed in the
// middle of the notification loop.
this.notifyNestedSubs = this.subscription.notifyNestedSubs.bind(this.subscription);
};
var _this2 = _possibleConstructorReturn(this, _OuterBaseComponent.call(this, props));
Connect.prototype.onStateChange = function onStateChange() {
this.runUpdater(this.notifyNestedSubs);
};
_this2.version = version;
Connect.prototype.isSubscribed = function isSubscribed() {
return Boolean(this.subscription) && this.subscription.isSubscribed();
};
_this2.renderInner = _this2.renderInner.bind(_this2);
Connect.prototype.addExtraProps = function addExtraProps(props) {
if (!withRef && !renderCountProp && !(this.propsMode && this.subscription)) return props;
// make a shallow copy so that fields added don't leak to the original selector.
// this is especially important for 'ref' since that's a reference back to the component
// instance. a singleton memoized selector would then be holding a reference to the
// instance, preventing the instance from being garbage collected, and that would be bad
var withExtras = _extends({}, props);
if (withRef) withExtras.ref = this.setWrappedInstance;
if (renderCountProp) withExtras[renderCountProp] = this.renderCount++;
if (this.propsMode && this.subscription) withExtras[subscriptionKey] = this.subscription;
return withExtras;
_this2.wrapperPropsMemoizer = createWrapperPropsMemoizer();
return _this2;
}
Connect.prototype.renderInner = function renderInner(providerValue) {
var storeState = providerValue.storeState,
store = providerValue.store;
var _wrapperPropsMemoizer = this.wrapperPropsMemoizer(this.props),
forwardRef = _wrapperPropsMemoizer.forwardRef,
wrapperProps = _wrapperPropsMemoizer.wrapperProps;
return _react2.default.createElement(ConnectInner, {
key: this.version,
storeState: storeState,
store: store,
wrapperProps: wrapperProps,
forwardRef: forwardRef
});
};
Connect.prototype.render = function render() {
if (this.state.error) {
throw this.state.error;
} else {
return (0, _react.createElement)(WrappedComponent, this.addExtraProps(this.state.props));
}
var ContextConsumer = this.props.contextConsumer || consumer;
return _react2.default.createElement(
ContextConsumer,
null,
this.renderInner
);
};
return Connect;
}(_react.Component);
}(OuterBaseComponent);
Connect.WrappedComponent = WrappedComponent;
Connect.displayName = displayName;
Connect.childContextTypes = childContextTypes;
Connect.contextTypes = contextTypes;
Connect.propTypes = contextTypes;
Connect.getDerivedStateFromProps = getDerivedStateFromProps;
Connect.propTypes = {
contextConsumer: _propTypes2.default.object,
forwardRef: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.object])
if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentDidUpdate = function componentDidUpdate() {
var _this3 = this;
// TODO We're losing the ability to add a store as a prop. Not sure there's anything we can do about that.
// We are hot reloading!
if (this.version !== version) {
this.version = version;
// If any connected descendants don't hot reload (and resubscribe in the process), their
// listeners will be lost when we unsubscribe. Unfortunately, by copying over all
// listeners, this does mean that the old versions of connected descendants will still be
// notified of state changes; however, their onStateChange function is a no-op so this
// isn't a huge deal.
var oldListeners = [];
};var wrapperComponent = Connect;
if (this.subscription) {
oldListeners = this.subscription.listeners.get();
this.subscription.tryUnsubscribe();
}
this.initSubscription();
if (shouldHandleStateChanges) {
this.subscription.trySubscribe();
oldListeners.forEach(function (listener) {
return _this3.subscription.listeners.subscribe(listener);
});
}
if (forwardRef) {
var forwarded = _react2.default.forwardRef(function (props, ref) {
return _react2.default.createElement(Connect, _extends({}, props, { forwardRef: ref }));
});
var updater = this.createUpdater();
this.setState({ updater: updater });
this.runUpdater();
}
};
wrapperComponent = forwarded;
}
(0, _reactLifecyclesCompat.polyfill)(Connect);
return (0, _hoistNonReactStatics2.default)(Connect, WrappedComponent);
return (0, _hoistNonReactStatics2.default)(wrapperComponent, WrappedComponent);
};
}

@@ -8,2 +8,4 @@ 'use strict';

var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');

@@ -19,2 +21,4 @@

var _context = require('./context');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -39,28 +43,77 @@

function createProvider() {
var _Provider$childContex;
var storeKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'store';
var subscriptionKey = storeKey + 'Subscription';
var Provider = function (_Component) {
_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
var _ref;
function Provider(props) {
_classCallCheck(this, Provider);
return _ref = {}, _ref[storeKey] = this[storeKey], _ref[subscriptionKey] = null, _ref;
};
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
function Provider(props, context) {
_classCallCheck(this, Provider);
var store = props.store;
var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
_this[storeKey] = props.store;
_this.state = {
storeState: store.getState(),
store: store
};
return _this;
}
Provider.prototype.componentDidMount = function componentDidMount() {
this._isMounted = true;
this.subscribe();
};
Provider.prototype.componentWillUnmount = function componentWillUnmount() {
if (this.unsubscribe) this.unsubscribe();
this._isMounted = false;
};
Provider.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
if (this.props.store !== prevProps.store) {
if (this.unsubscribe) this.unsubscribe();
this.subscribe();
}
};
Provider.prototype.subscribe = function subscribe() {
var _this2 = this;
var store = this.props.store;
this.unsubscribe = store.subscribe(function () {
var newStoreState = store.getState();
if (!_this2._isMounted) {
return;
}
_this2.setState(function (providerState) {
// If the value is the same, skip the unnecessary state update.
if (providerState.storeState === newStoreState) {
return null;
}
return { storeState: newStoreState };
});
});
// Actions might have been dispatched between render and mount - handle those
var postMountStoreState = store.getState();
if (postMountStoreState !== this.state.storeState) {
this.setState({ storeState: postMountStoreState });
}
};
Provider.prototype.render = function render() {
return _react.Children.only(this.props.children);
var ContextProvider = this.props.contextProvider || _context.ReactReduxContext.Provider;
return _react2.default.createElement(
ContextProvider,
{ value: this.state },
this.props.children
);
};

@@ -71,15 +124,7 @@

if (process.env.NODE_ENV !== 'production') {
Provider.prototype.componentDidUpdate = function () {
if (this[storeKey] !== this.props.store) {
warnAboutReceivingStore();
}
};
}
Provider.propTypes = {
store: _PropTypes.storeShape.isRequired,
children: _propTypes2.default.element.isRequired
children: _propTypes2.default.element.isRequired,
contextProvider: _propTypes2.default.object
};
Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[storeKey] = _PropTypes.storeShape.isRequired, _Provider$childContex[subscriptionKey] = _PropTypes.subscriptionShape, _Provider$childContex);

@@ -86,0 +131,0 @@ return Provider;

'use strict';
exports.__esModule = true;
exports.storeShape = exports.subscriptionShape = undefined;
exports.storeShape = undefined;

@@ -12,9 +12,2 @@ var _propTypes = require('prop-types');

var subscriptionShape = exports.subscriptionShape = _propTypes2.default.shape({
trySubscribe: _propTypes2.default.func.isRequired,
tryUnsubscribe: _propTypes2.default.func.isRequired,
notifyNestedSubs: _propTypes2.default.func.isRequired,
isSubscribed: _propTypes2.default.func.isRequired
});
var storeShape = exports.storeShape = _propTypes2.default.shape({

@@ -21,0 +14,0 @@ subscribe: _propTypes2.default.func.isRequired,

{
"name": "react-redux",
"version": "5.1.0-test.1",
"version": "6.0.0-alpha.9210282",
"description": "Official React bindings for Redux",

@@ -36,5 +36,5 @@ "keywords": [

"clean": "rimraf lib dist es coverage",
"lint": "eslint src test",
"lint": "eslint src test/utils test/components",
"prepare": "npm run clean && npm run build",
"test": "jest",
"test": "node ./test/run-tests.js",
"coverage": "codecov"

@@ -51,2 +51,3 @@ },

"prop-types": "^15.6.1",
"react-is": "^16.4.2",
"react-lifecycles-compat": "^3.0.0"

@@ -85,2 +86,3 @@ },

"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"es3ify": "^0.2.0",

@@ -91,6 +93,8 @@ "eslint": "^4.19.1",

"glob": "^7.1.1",
"jest": "^23.1.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-test-renderer": "^16.3.2",
"jest": "^23.4.1",
"jest-dom": "^1.12.0",
"npm-run": "^5.0.1",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-testing-library": "^5.0.0",
"redux": "^4.0.0",

@@ -103,3 +107,4 @@ "rimraf": "^2.6.2",

"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^3.0.0"
"rollup-plugin-uglify": "^3.0.0",
"semver": "^5.5.0"
},

@@ -110,7 +115,3 @@ "browserify": {

]
},
"jest": {
"coverageDirectory": "./coverage/",
"collectCoverage": true
}
}
import hoistStatics from 'hoist-non-react-statics'
import invariant from 'invariant'
import { Component, createElement } from 'react'
import { polyfill } from 'react-lifecycles-compat'
import PropTypes from 'prop-types'
import React, { Component, PureComponent } from 'react'
import { isValidElementType } from 'react-is'
import Subscription from '../utils/Subscription'
import { storeShape, subscriptionShape } from '../utils/PropTypes'
import {ReactReduxContext} from "./context"
import {storeShape} from "../utils/PropTypes"
let hotReloadingVersion = 0
function noop() {}
function makeUpdater(sourceSelector, store) {
return function updater(props, prevState) {
try {
const nextProps = sourceSelector(store.getState(), props)
if (nextProps !== prevState.props || prevState.error) {
return {
shouldComponentUpdate: true,
props: nextProps,
error: null,
}
}
return {
shouldComponentUpdate: false,
}
} catch (error) {
return {
shouldComponentUpdate: true,
error,
}
}
}
}
export default function connectAdvanced(

@@ -63,15 +42,18 @@ /*

// if defined, the name of the property passed to the wrapped element indicating the number of
// calls to render. useful for watching in react devtools for unnecessary re-renders.
renderCountProp = undefined,
// determines whether this HOC subscribes to store changes
shouldHandleStateChanges = true,
// the key of props/context to get the store
// the context consumer to use
consumer = ReactReduxContext.Consumer,
// REMOVED: the key of props/context to get the store
storeKey = 'store',
// if true, the wrapped element is exposed by this HOC via the getWrappedInstance() function.
// REMOVED: expose the wrapped component via refs
withRef = false,
// use React's forwardRef to expose a ref of the wrapped component
forwardRef = false,
// additional options are passed through to the selectorFactory

@@ -81,20 +63,20 @@ ...connectOptions

) {
const subscriptionKey = storeKey + 'Subscription'
invariant(!withRef,
"withRef is removed. To access the wrapped instance, use a ref on the connected component"
)
invariant(storeKey === 'store',
'storeKey has been removed. To use a custom redux store for a single component, ' +
'create a custom React context with React.createContext() and pass the Provider to react-redux\'s provider ' +
'and the Consumer to this component as in <Provider context={context.Provider}><' +
'ConnectedComponent consumer={context.Consumer} /></Provider>'
)
const version = hotReloadingVersion++
const contextTypes = {
[storeKey]: storeShape,
[subscriptionKey]: subscriptionShape,
}
const childContextTypes = {
[subscriptionKey]: subscriptionShape,
}
function getDerivedStateFromProps(nextProps, prevState) {
return prevState.updater(nextProps, prevState)
}
return function wrapWithConnect(WrappedComponent) {
invariant(
typeof WrappedComponent == 'function',
isValidElementType(WrappedComponent),
`You must pass a component to the function returned by ` +

@@ -114,6 +96,3 @@ `${methodName}. Instead received ${JSON.stringify(WrappedComponent)}`

methodName,
renderCountProp,
shouldHandleStateChanges,
storeKey,
withRef,
displayName,

@@ -124,127 +103,131 @@ wrappedComponentName,

class Connect extends Component {
constructor(props, context) {
super(props, context)
this.version = version
this.renderCount = 0
this.store = props[storeKey] || context[storeKey]
this.propsMode = Boolean(props[storeKey])
this.setWrappedInstance = this.setWrappedInstance.bind(this)
const OuterBaseComponent = connectOptions.pure ? PureComponent : Component
invariant(this.store,
`Could not find "${storeKey}" in either the context or props of ` +
`"${displayName}". Either wrap the root component in a <Provider>, ` +
`or explicitly pass "${storeKey}" as a prop to "${displayName}".`
)
function createChildSelector(store) {
return selectorFactory(store.dispatch, selectorFactoryOptions)
}
class ConnectInner extends Component {
constructor(props) {
super(props)
this.state = {
updater: this.createUpdater()
wrapperProps : props.wrapperProps,
store : props.store,
error : null,
childPropsSelector : createChildSelector(props.store),
childProps : {},
}
this.initSubscription()
}
getChildContext() {
// If this component received store from props, its subscription should be transparent
// to any descendants receiving store+subscription from context; it passes along
// subscription passed to it. Otherwise, it shadows the parent subscription, which allows
// Connect to control ordering of notifications to flow top-down.
const subscription = this.propsMode ? null : this.subscription
return { [subscriptionKey]: subscription || this.context[subscriptionKey] }
this.state = {
...this.state,
...ConnectInner.getChildPropsState(props, this.state)
}
}
componentDidMount() {
if (!shouldHandleStateChanges) return
// componentWillMount fires during server side rendering, but componentDidMount and
// componentWillUnmount do not. Because of this, trySubscribe happens during ...didMount.
// Otherwise, unsubscription would never take place during SSR, causing a memory leak.
// To handle the case where a child component may have triggered a state change by
// dispatching an action in its componentWillMount, we have to re-run the select and maybe
// re-render.
this.subscription.trySubscribe()
this.runUpdater()
}
shouldComponentUpdate(_, nextState) {
return nextState.shouldComponentUpdate
}
static getChildPropsState(props, state) {
try {
let {childPropsSelector} = state
componentWillUnmount() {
if (this.subscription) this.subscription.tryUnsubscribe()
this.subscription = null
this.notifyNestedSubs = noop
this.store = null
this.isUnmounted = true
}
if(props.store !== state.store) {
childPropsSelector = createChildSelector(props.store)
}
getWrappedInstance() {
invariant(withRef,
`To access the wrapped instance, you need to specify ` +
`{ withRef: true } in the options argument of the ${methodName}() call.`
)
return this.wrappedInstance
const nextProps = childPropsSelector(props.storeState, props.wrapperProps)
if (nextProps === state.childProps) return null
return { childProps: nextProps, store : props.store, childPropsSelector }
} catch (error) {
return { error }
}
}
setWrappedInstance(ref) {
this.wrappedInstance = ref
static getDerivedStateFromProps(props, state) {
const nextChildProps = ConnectInner.getChildPropsState(props, state)
if(nextChildProps === null) {
return null
}
return {
...nextChildProps,
wrapperProps : props.wrapperProps,
}
}
createUpdater() {
const sourceSelector = selectorFactory(this.store.dispatch, selectorFactoryOptions)
return makeUpdater(sourceSelector, this.store)
shouldComponentUpdate(nextProps, nextState) {
const childPropsChanged = nextState.childProps !== this.state.childProps
const hasError = !!nextState.error
return childPropsChanged || hasError
}
runUpdater(callback = noop) {
if (this.isUnmounted) {
return
render() {
if(this.state.error) {
throw this.state.error
}
this.setState(prevState => prevState.updater(this.props, prevState), callback)
return <WrappedComponent {...this.state.childProps} ref={this.props.forwardRef} />
}
}
initSubscription() {
if (!shouldHandleStateChanges) return
ConnectInner.propTypes = {
wrapperProps : PropTypes.object,
store : storeShape,
}
// parentSub's source should match where store came from: props vs. context. A component
// connected to the store via props shouldn't use subscription from context, or vice versa.
const parentSub = (this.propsMode ? this.props : this.context)[subscriptionKey]
this.subscription = new Subscription(this.store, parentSub, this.onStateChange.bind(this))
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
// the middle of the notification loop, where `this.subscription` will then be null. An
// extra null check every change can be avoided by copying the method onto `this` and then
// replacing it with a no-op on unmount. This can probably be avoided if Subscription's
// listeners logic is changed to not call listeners that have been unsubscribed in the
// middle of the notification loop.
this.notifyNestedSubs = this.subscription.notifyNestedSubs.bind(this.subscription)
}
function createWrapperPropsMemoizer() {
let result, prevProps
onStateChange() {
this.runUpdater(this.notifyNestedSubs)
return function wrapperPropsMemoizer(props) {
if(props === prevProps) {
return result
}
const {contextConsumer, forwardRef, ...wrapperProps} = props
result = {contextConsumer, forwardRef, wrapperProps}
return result
}
}
isSubscribed() {
return Boolean(this.subscription) && this.subscription.isSubscribed()
class Connect extends OuterBaseComponent {
constructor(props) {
super(props)
this.version = version
this.renderInner = this.renderInner.bind(this)
this.wrapperPropsMemoizer = createWrapperPropsMemoizer()
}
addExtraProps(props) {
if (!withRef && !renderCountProp && !(this.propsMode && this.subscription)) return props
// make a shallow copy so that fields added don't leak to the original selector.
// this is especially important for 'ref' since that's a reference back to the component
// instance. a singleton memoized selector would then be holding a reference to the
// instance, preventing the instance from being garbage collected, and that would be bad
const withExtras = { ...props }
if (withRef) withExtras.ref = this.setWrappedInstance
if (renderCountProp) withExtras[renderCountProp] = this.renderCount++
if (this.propsMode && this.subscription) withExtras[subscriptionKey] = this.subscription
return withExtras
renderInner(providerValue) {
const {storeState, store} = providerValue
const {forwardRef, wrapperProps} = this.wrapperPropsMemoizer(this.props)
return (
<ConnectInner
key={this.version}
storeState={storeState}
store={store}
wrapperProps={wrapperProps}
forwardRef={forwardRef}
/>
)
}
render() {
if (this.state.error) {
throw this.state.error
} else {
return createElement(WrappedComponent, this.addExtraProps(this.state.props))
}
const ContextConsumer = this.props.contextConsumer || consumer
return (
<ContextConsumer>
{this.renderInner}
</ContextConsumer>
)
}

@@ -255,41 +238,25 @@ }

Connect.displayName = displayName
Connect.childContextTypes = childContextTypes
Connect.contextTypes = contextTypes
Connect.propTypes = contextTypes
Connect.getDerivedStateFromProps = getDerivedStateFromProps
Connect.propTypes = {
contextConsumer: PropTypes.object,
forwardRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.object
])
}
if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentDidUpdate = function componentDidUpdate() {
// We are hot reloading!
if (this.version !== version) {
this.version = version
// TODO We're losing the ability to add a store as a prop. Not sure there's anything we can do about that.
// If any connected descendants don't hot reload (and resubscribe in the process), their
// listeners will be lost when we unsubscribe. Unfortunately, by copying over all
// listeners, this does mean that the old versions of connected descendants will still be
// notified of state changes; however, their onStateChange function is a no-op so this
// isn't a huge deal.
let oldListeners = [];
if (this.subscription) {
oldListeners = this.subscription.listeners.get()
this.subscription.tryUnsubscribe()
}
this.initSubscription()
if (shouldHandleStateChanges) {
this.subscription.trySubscribe()
oldListeners.forEach(listener => this.subscription.listeners.subscribe(listener))
}
let wrapperComponent = Connect
const updater = this.createUpdater()
this.setState({updater})
this.runUpdater()
}
}
if(forwardRef) {
const forwarded = React.forwardRef(function (props, ref) {
return <Connect {...props} forwardRef={ref} />
})
wrapperComponent = forwarded
}
polyfill(Connect)
return hoistStatics(Connect, WrappedComponent)
return hoistStatics(wrapperComponent, WrappedComponent)
}
}

@@ -1,6 +0,8 @@

import { Component, Children } from 'react'
import React, { Component, Children } from 'react'
import PropTypes from 'prop-types'
import { storeShape, subscriptionShape } from '../utils/PropTypes'
import { storeShape } from '../utils/PropTypes'
import warning from '../utils/warning'
import {ReactReduxContext} from "./context"
let didWarnAboutReceivingStore = false

@@ -22,36 +24,80 @@ function warnAboutReceivingStore() {

export function createProvider(storeKey = 'store') {
const subscriptionKey = `${storeKey}Subscription`
export function createProvider() {
class Provider extends Component {
getChildContext() {
return { [storeKey]: this[storeKey], [subscriptionKey]: null }
constructor(props) {
super(props)
const {store} = props
this.state = {
storeState : store.getState(),
store,
}
}
constructor(props, context) {
super(props, context)
this[storeKey] = props.store;
componentDidMount() {
this._isMounted = true
this.subscribe()
}
render() {
return Children.only(this.props.children)
componentWillUnmount() {
if(this.unsubscribe) this.unsubscribe()
this._isMounted = false
}
}
if (process.env.NODE_ENV !== 'production') {
Provider.prototype.componentDidUpdate = function () {
if (this[storeKey] !== this.props.store) {
warnAboutReceivingStore()
componentDidUpdate(prevProps) {
if(this.props.store !== prevProps.store) {
if(this.unsubscribe) this.unsubscribe()
this.subscribe()
}
}
}
subscribe() {
const {store} = this.props
this.unsubscribe = store.subscribe( () => {
const newStoreState = store.getState()
if(!this._isMounted) {
return
}
this.setState(providerState => {
// If the value is the same, skip the unnecessary state update.
if(providerState.storeState === newStoreState) {
return null
}
return {storeState : newStoreState}
})
})
// Actions might have been dispatched between render and mount - handle those
const postMountStoreState = store.getState()
if(postMountStoreState !== this.state.storeState) {
this.setState({storeState : postMountStoreState})
}
}
render() {
const ContextProvider = this.props.contextProvider || ReactReduxContext.Provider
return (
<ContextProvider value={this.state}>
{this.props.children}
</ContextProvider>
)
}
}
Provider.propTypes = {
store: storeShape.isRequired,
children: PropTypes.element.isRequired,
store: storeShape.isRequired,
children: PropTypes.element.isRequired,
contextProvider : PropTypes.object,
}
Provider.childContextTypes = {
[storeKey]: storeShape.isRequired,
[subscriptionKey]: subscriptionShape,
}

@@ -58,0 +104,0 @@ return Provider

import PropTypes from 'prop-types'
export const subscriptionShape = PropTypes.shape({
trySubscribe: PropTypes.func.isRequired,
tryUnsubscribe: PropTypes.func.isRequired,
notifyNestedSubs: PropTypes.func.isRequired,
isSubscribed: PropTypes.func.isRequired,
})
export const storeShape = PropTypes.shape({

@@ -11,0 +4,0 @@ subscribe: PropTypes.func.isRequired,

Sorry, the diff of this file is too big to display

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