Socket
Socket
Sign inDemoInstall

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

Comparing version 7.1.3 to 7.2.0

2

dist/react-redux.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("redux"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","redux","react-dom"],t):t((e=e||self).ReactRedux={},e.React,e.Redux,e.ReactDOM)}(this,function(e,t,r,n){"use strict";var o="default"in t?t.default:t;function u(e,t){return e(t={exports:{}},t.exports),t.exports}var i="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";function a(){}function c(){}c.resetWarningCache=a;var s=u(function(e){e.exports=function(){function e(e,t,r,n,o,u){if(u!==i){var a=Error("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");throw a.name="Invariant Violation",a}}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,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:c,resetWarningCache:a};return r.PropTypes=r,r}()}),f=o.createContext(null);var p=function(e){e()},d=function(){return p},l=null,y={notify:function(){}};var v=function(){function e(e,t){this.store=e,this.parentSub=t,this.unsubscribe=null,this.listeners=y,this.handleChangeWrapper=this.handleChangeWrapper.bind(this)}var t=e.prototype;return t.addNestedSub=function(e){return this.trySubscribe(),this.listeners.subscribe(e)},t.notifyNestedSubs=function(){this.listeners.notify()},t.handleChangeWrapper=function(){this.onStateChange&&this.onStateChange()},t.isSubscribed=function(){return!!this.unsubscribe},t.trySubscribe=function(){this.unsubscribe||(this.unsubscribe=this.parentSub?this.parentSub.addNestedSub(this.handleChangeWrapper):this.store.subscribe(this.handleChangeWrapper),this.listeners=function(){var e=d(),t=[],r=[];return{clear:function(){r=l,t=l},notify:function(){var n=t=r;e(function(){for(var e=0;n.length>e;e++)n[e]()})},get:function(){return r},subscribe:function(e){var n=!0;return r===t&&(r=t.slice()),r.push(e),function(){n&&t!==l&&(n=!1,r===t&&(r=t.slice()),r.splice(r.indexOf(e),1))}}}}())},t.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.listeners.clear(),this.listeners=y)},e}();function m(e){var r=e.store,n=e.context,u=e.children,i=t.useMemo(function(){var e=new v(r);return e.onStateChange=e.notifyNestedSubs,{store:r,subscription:e}},[r]),a=t.useMemo(function(){return r.getState()},[r]);return t.useEffect(function(){var e=i.subscription;return e.trySubscribe(),a!==r.getState()&&e.notifyNestedSubs(),function(){e.tryUnsubscribe(),e.onStateChange=null}},[i,a]),o.createElement((n||f).Provider,{value:i},u)}function h(){return(h=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}).apply(this,arguments)}function b(e,t){if(null==e)return{};var r,n,o={},u=Object.keys(e);for(n=0;u.length>n;n++)0>t.indexOf(r=u[n])&&(o[r]=e[r]);return o}m.propTypes={store:s.shape({subscribe:s.func.isRequired,dispatch:s.func.isRequired,getState:s.func.isRequired}),context:s.object,children:s.any};var P,S=u(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,u=r?Symbol.for("react.fragment"):60107,i=r?Symbol.for("react.strict_mode"):60108,a=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,s=r?Symbol.for("react.context"):60110,f=r?Symbol.for("react.async_mode"):60111,p=r?Symbol.for("react.concurrent_mode"):60111,d=r?Symbol.for("react.forward_ref"):60112,l=r?Symbol.for("react.suspense"):60113,y=r?Symbol.for("react.suspense_list"):60120,v=r?Symbol.for("react.memo"):60115,m=r?Symbol.for("react.lazy"):60116,h=r?Symbol.for("react.fundamental"):60117,b=r?Symbol.for("react.responder"):60118;function P(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case f:case p:case u:case a:case i:case l:return e;default:switch(e=e&&e.$$typeof){case s:case d:case c:return e;default:return t}}case m:case v:case o:return t}}}function S(e){return P(e)===p}t.typeOf=P,t.AsyncMode=f,t.ConcurrentMode=p,t.ContextConsumer=s,t.ContextProvider=c,t.Element=n,t.ForwardRef=d,t.Fragment=u,t.Lazy=m,t.Memo=v,t.Portal=o,t.Profiler=a,t.StrictMode=i,t.Suspense=l,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===u||e===p||e===a||e===i||e===l||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===v||e.$$typeof===c||e.$$typeof===s||e.$$typeof===d||e.$$typeof===h||e.$$typeof===b)},t.isAsyncMode=function(e){return S(e)||P(e)===f},t.isConcurrentMode=S,t.isContextConsumer=function(e){return P(e)===s},t.isContextProvider=function(e){return P(e)===c},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return P(e)===d},t.isFragment=function(e){return P(e)===u},t.isLazy=function(e){return P(e)===m},t.isMemo=function(e){return P(e)===v},t.isPortal=function(e){return P(e)===o},t.isProfiler=function(e){return P(e)===a},t.isStrictMode=function(e){return P(e)===i},t.isSuspense=function(e){return P(e)===l}});(P=S)&&P.__esModule&&Object.prototype.hasOwnProperty.call(P,"default");var g=u(function(e){e.exports=S}),O=g.isContextConsumer,w={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},C={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},x={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},R={};function E(e){return g.isMemo(e)?x:R[e.$$typeof]||w}R[g.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0};var M=Object.defineProperty,T=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols,$=Object.getOwnPropertyDescriptor,N=Object.getPrototypeOf,q=Object.prototype;var _=function e(t,r,n){if("string"!=typeof r){if(q){var o=N(r);o&&o!==q&&e(t,o,n)}var u=T(r);j&&(u=u.concat(j(r)));for(var i=E(t),a=E(r),c=0;u.length>c;++c){var s=u[c];if(!(C[s]||n&&n[s]||a&&a[s]||i&&i[s])){var f=$(r,s);try{M(t,s,f)}catch(e){}}}return t}return t},D=function(e,t,r,n,o,u,i,a){if(!e){var c;if(void 0===t)c=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[r,n,o,u,i,a],f=0;(c=Error(t.replace(/%s/g,function(){return s[f++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}},k="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect,F=[],W=[null,null];function A(e,t){return[t.payload,e[1]+1]}var H=function(){return[null,0]};function U(e,r){void 0===r&&(r={});var n=r.getDisplayName,u=void 0===n?function(e){return"ConnectAdvanced("+e+")"}:n,i=r.methodName,a=void 0===i?"connectAdvanced":i,c=r.renderCountProp,s=void 0===c?void 0:c,p=r.shouldHandleStateChanges,d=void 0===p||p,l=r.storeKey,y=void 0===l?"store":l,m=r.withRef,P=void 0!==m&&m,S=r.forwardRef,g=void 0!==S&&S,w=r.context,C=void 0===w?f:w,x=b(r,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef","forwardRef","context"]);D(void 0===s,"renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension"),D(!P,"withRef is removed. To access the wrapped instance, use a ref on the connected component");D("store"===y,"storeKey has been removed and does not do anything. To use a custom Redux store for specific components, create a custom React context with React.createContext(), and pass the context object to React Redux's Provider and specific components like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. You may also pass a {context : MyContext} option to connect");var R=C;return function(r){var n=r.displayName||r.name||"Component",i=u(n),c=h({},x,{getDisplayName:u,methodName:a,renderCountProp:s,shouldHandleStateChanges:d,storeKey:y,displayName:i,wrappedComponentName:n,WrappedComponent:r}),f=x.pure;var p=f?t.useMemo:function(e){return e()};function l(n){var u=t.useMemo(function(){var e=n.forwardedRef,t=b(n,["forwardedRef"]);return[n.context,e,t]},[n]),a=u[0],s=u[1],f=u[2],l=t.useMemo(function(){return a&&a.Consumer&&O(o.createElement(a.Consumer,null))?a:R},[a,R]),y=t.useContext(l),m=!!n.store&&!!n.store.getState&&!!n.store.dispatch;D(m||!!y&&!!y.store,'Could not find "store" in the context of "'+i+'". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to '+i+" in connect options.");var P=m?n.store:y.store,S=t.useMemo(function(){return function(t){return e(t.dispatch,c)}(P)},[P]),g=t.useMemo(function(){if(!d)return W;var e=new v(P,m?null:y.subscription),t=e.notifyNestedSubs.bind(e);return[e,t]},[P,m,y]),w=g[0],C=g[1],x=t.useMemo(function(){return m?y:h({},y,{subscription:w})},[m,y,w]),E=t.useReducer(A,F,H),M=E[0][0],T=E[1];if(M&&M.error)throw M.error;var j=t.useRef(),$=t.useRef(f),N=t.useRef(),q=t.useRef(!1),_=p(function(){return N.current&&f===$.current?N.current:S(P.getState(),f)},[P,M,f]);k(function(){$.current=f,j.current=_,q.current=!1,N.current&&(N.current=null,C())}),k(function(){if(d){var e=!1,t=null,r=function(){if(!e){var r,n,o=P.getState();try{r=S(o,$.current)}catch(e){n=e,t=e}n||(t=null),r===j.current?q.current||C():(j.current=r,N.current=r,q.current=!0,T({type:"STORE_UPDATED",payload:{error:n}}))}};w.onStateChange=r,w.trySubscribe(),r();return function(){if(e=!0,w.tryUnsubscribe(),w.onStateChange=null,t)throw t}}},[P,w,S]);var U=t.useMemo(function(){return o.createElement(r,h({},_,{ref:s}))},[s,r,_]);return t.useMemo(function(){return d?o.createElement(l.Provider,{value:x},U):U},[l,U,x])}var m=f?o.memo(l):l;if(m.WrappedComponent=r,m.displayName=i,g){var P=o.forwardRef(function(e,t){return o.createElement(m,h({},e,{forwardedRef:t}))});return P.displayName=i,P.WrappedComponent=r,_(P,r)}return _(m,r)}}var I=Object.prototype.hasOwnProperty;function L(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function K(e,t){if(L(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(!I.call(t,r[n])||!L(e[r[n]],t[r[n]]))return!1;return!0}function z(e){return function(t,r){var n=e(t,r);function o(){return n}return o.dependsOnOwnProps=!1,o}}function V(e){return null!=e.dependsOnOwnProps?!!e.dependsOnOwnProps:1!==e.length}function Y(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=V(e);var o=n(t,r);return"function"==typeof o&&(n.mapToProps=o,n.dependsOnOwnProps=V(o),o=n(t,r)),o},n}}function B(e,t,r){return h({},r,{},e,{},t)}var G=[function(e){return"function"==typeof e?function(e){return function(t,r){var n,o=r.pure,u=r.areMergedPropsEqual,i=!1;return function(t,r,a){var c=e(t,r,a);return i?o&&u(c,n)||(n=c):(i=!0,n=c),n}}}(e):void 0},function(e){return e?void 0:function(){return B}}];function J(e,t,r,n){return function(o,u){return r(e(o,u),t(n,u),u)}}function Q(e,t,r,n,o){var u,i,a,c,s,f=o.areStatesEqual,p=o.areOwnPropsEqual,d=o.areStatePropsEqual,l=!1;function y(o,l){var y,v,m=!p(l,i),h=!f(o,u);return u=o,i=l,m&&h?(a=e(u,i),t.dependsOnOwnProps&&(c=t(n,i)),s=r(a,c,i)):m?(e.dependsOnOwnProps&&(a=e(u,i)),t.dependsOnOwnProps&&(c=t(n,i)),s=r(a,c,i)):h?(y=e(u,i),v=!d(y,a),a=y,v&&(s=r(a,c,i)),s):s}return function(o,f){return l?y(o,f):(a=e(u=o,i=f),c=t(n,i),s=r(a,c,i),l=!0,s)}}function X(e,t){var r=t.initMapStateToProps,n=t.initMapDispatchToProps,o=t.initMergeProps,u=b(t,["initMapStateToProps","initMapDispatchToProps","initMergeProps"]),i=r(e,u),a=n(e,u),c=o(e,u);return(u.pure?Q:J)(i,a,c,e,u)}function Z(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 ee(e,t){return e===t}var te,re,ne,oe,ue,ie,ae,ce,se,fe,pe,de,le=(oe=void 0===(ne=(re=void 0===te?{}:te).connectHOC)?U:ne,ie=void 0===(ue=re.mapStateToPropsFactories)?[function(e){return"function"==typeof e?Y(e):void 0},function(e){return e?void 0:z(function(){return{}})}]:ue,ce=void 0===(ae=re.mapDispatchToPropsFactories)?[function(e){return"function"==typeof e?Y(e):void 0},function(e){return e?void 0:z(function(e){return{dispatch:e}})},function(e){return e&&"object"==typeof e?z(function(t){return r.bindActionCreators(e,t)}):void 0}]:ae,fe=void 0===(se=re.mergePropsFactories)?G:se,de=void 0===(pe=re.selectorFactory)?X:pe,function(e,t,r,n){void 0===n&&(n={});var o=n.pure,u=void 0===o||o,i=n.areStatesEqual,a=void 0===i?ee:i,c=n.areOwnPropsEqual,s=void 0===c?K:c,f=n.areStatePropsEqual,p=void 0===f?K:f,d=n.areMergedPropsEqual,l=void 0===d?K:d,y=b(n,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),v=Z(e,ie,"mapStateToProps"),m=Z(t,ce,"mapDispatchToProps"),P=Z(r,fe,"mergeProps");return oe(de,h({methodName:"connect",getDisplayName:function(e){return"Connect("+e+")"},shouldHandleStateChanges:!!e,initMapStateToProps:v,initMapDispatchToProps:m,initMergeProps:P,pure:u,areStatesEqual:a,areOwnPropsEqual:s,areStatePropsEqual:p,areMergedPropsEqual:l},y))});function ye(){var e=t.useContext(f);return D(e,"could not find react-redux context value; please ensure the component is wrapped in a <Provider>"),e}function ve(e){void 0===e&&(e=f);var r=e===f?ye:function(){return t.useContext(e)};return function(){return r().store}}var me=ve();function he(e){void 0===e&&(e=f);var t=e===f?me:ve(e);return function(){return t().dispatch}}var be=he(),Pe=function(e,t){return e===t};function Se(e){void 0===e&&(e=f);var r=e===f?ye:function(){return t.useContext(e)};return function(e,n){void 0===n&&(n=Pe),D(e,"You must pass a selector to useSelectors");var o=r();return function(e,r,n,o){var u,i=t.useReducer(function(e){return e+1},0)[1],a=t.useMemo(function(){return new v(n,o)},[n,o]),c=t.useRef(),s=t.useRef(),f=t.useRef();try{u=e!==s.current||c.current?e(n.getState()):f.current}catch(e){var p="An error occurred while selecting the store state: "+e.message+".";throw c.current&&(p+="\nThe error may be correlated with this previous error:\n"+c.current.stack+"\n\nOriginal stack trace:"),Error(p)}return k(function(){s.current=e,f.current=u,c.current=void 0}),k(function(){function e(){try{var e=s.current(n.getState());if(r(e,f.current))return;f.current=e}catch(e){c.current=e}i({})}return a.onStateChange=e,a.trySubscribe(),e(),function(){return a.tryUnsubscribe()}},[n,a]),u}(e,n,o.store,o.subscription)}}var ge=Se();p=n.unstable_batchedUpdates,Object.defineProperty(e,"batch",{enumerable:!0,get:function(){return n.unstable_batchedUpdates}}),e.Provider=m,e.ReactReduxContext=f,e.connect=le,e.connectAdvanced=U,e.createDispatchHook=he,e.createSelectorHook=Se,e.createStoreHook=ve,e.shallowEqual=K,e.useDispatch=be,e.useSelector=ge,e.useStore=me,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("redux"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","redux","react-dom"],t):t((e=e||self).ReactRedux={},e.React,e.Redux,e.ReactDOM)}(this,function(e,t,r,n){"use strict";var o="default"in t?t.default:t;function u(e,t){return e(t={exports:{}},t.exports),t.exports}var a="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";function i(){}function c(){}c.resetWarningCache=i;u(function(e){e.exports=function(){function e(e,t,r,n,o,u){if(u!==a){var i=Error("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");throw i.name="Invariant Violation",i}}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,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:c,resetWarningCache:i};return r.PropTypes=r,r}()});var s=o.createContext(null);var f=function(e){e()},p=function(){return f},l={notify:function(){}};var d=function(){function e(e,t){this.store=e,this.parentSub=t,this.unsubscribe=null,this.listeners=l,this.handleChangeWrapper=this.handleChangeWrapper.bind(this)}var t=e.prototype;return t.addNestedSub=function(e){return this.trySubscribe(),this.listeners.subscribe(e)},t.notifyNestedSubs=function(){this.listeners.notify()},t.handleChangeWrapper=function(){this.onStateChange&&this.onStateChange()},t.isSubscribed=function(){return!!this.unsubscribe},t.trySubscribe=function(){this.unsubscribe||(this.unsubscribe=this.parentSub?this.parentSub.addNestedSub(this.handleChangeWrapper):this.store.subscribe(this.handleChangeWrapper),this.listeners=function(){var e=p(),t=null,r=null;return{clear:function(){t=null,r=null},notify:function(){e(function(){for(var e=t;e;)e.callback(),e=e.next})},get:function(){for(var e=[],r=t;r;)e.push(r),r=r.next;return e},subscribe:function(e){var n=!0,o=r={callback:e,next:null,prev:r};return o.prev?o.prev.next=o:t=o,function(){n&&null!==t&&(n=!1,o.next?o.next.prev=o.prev:r=o.prev,o.prev?o.prev.next=o.next:t=o.next)}}}}())},t.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.listeners.clear(),this.listeners=l)},e}();function y(){return(y=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}).apply(this,arguments)}function v(e,t){if(null==e)return{};var r,n,o={},u=Object.keys(e);for(n=0;u.length>n;n++)0>t.indexOf(r=u[n])&&(o[r]=e[r]);return o}var m,b=u(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,u=r?Symbol.for("react.fragment"):60107,a=r?Symbol.for("react.strict_mode"):60108,i=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,s=r?Symbol.for("react.context"):60110,f=r?Symbol.for("react.async_mode"):60111,p=r?Symbol.for("react.concurrent_mode"):60111,l=r?Symbol.for("react.forward_ref"):60112,d=r?Symbol.for("react.suspense"):60113,y=r?Symbol.for("react.suspense_list"):60120,v=r?Symbol.for("react.memo"):60115,m=r?Symbol.for("react.lazy"):60116,b=r?Symbol.for("react.fundamental"):60117,h=r?Symbol.for("react.responder"):60118;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case f:case p:case u:case i:case a:case d:return e;default:switch(e=e&&e.$$typeof){case s:case l:case c:return e;default:return t}}case m:case v:case o:return t}}}function P(e){return S(e)===p}t.typeOf=S,t.AsyncMode=f,t.ConcurrentMode=p,t.ContextConsumer=s,t.ContextProvider=c,t.Element=n,t.ForwardRef=l,t.Fragment=u,t.Lazy=m,t.Memo=v,t.Portal=o,t.Profiler=i,t.StrictMode=a,t.Suspense=d,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===u||e===p||e===i||e===a||e===d||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===v||e.$$typeof===c||e.$$typeof===s||e.$$typeof===l||e.$$typeof===b||e.$$typeof===h)},t.isAsyncMode=function(e){return P(e)||S(e)===f},t.isConcurrentMode=P,t.isContextConsumer=function(e){return S(e)===s},t.isContextProvider=function(e){return S(e)===c},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return S(e)===l},t.isFragment=function(e){return S(e)===u},t.isLazy=function(e){return S(e)===m},t.isMemo=function(e){return S(e)===v},t.isPortal=function(e){return S(e)===o},t.isProfiler=function(e){return S(e)===i},t.isStrictMode=function(e){return S(e)===a},t.isSuspense=function(e){return S(e)===d}});(m=b)&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default");var h=u(function(e){e.exports=b}),S=h.isContextConsumer,P={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},g={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},O={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},w={};function C(e){return h.isMemo(e)?O:w[e.$$typeof]||P}w[h.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0};var x=Object.defineProperty,E=Object.getOwnPropertyNames,M=Object.getOwnPropertySymbols,T=Object.getOwnPropertyDescriptor,R=Object.getPrototypeOf,$=Object.prototype;var j=function e(t,r,n){if("string"!=typeof r){if($){var o=R(r);o&&o!==$&&e(t,o,n)}var u=E(r);M&&(u=u.concat(M(r)));for(var a=C(t),i=C(r),c=0;u.length>c;++c){var s=u[c];if(!(g[s]||n&&n[s]||i&&i[s]||a&&a[s])){var f=T(r,s);try{x(t,s,f)}catch(e){}}}return t}return t},N="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect,_=[],q=[null,null];function D(e,t){return[t.payload,e[1]+1]}function k(e,t,r){N(function(){return e.apply(void 0,t)},r)}function F(e,t,r,n,o,u,a){e.current=n,t.current=o,r.current=!1,u.current&&(u.current=null,a())}function W(e,t,r,n,o,u,a,i,c,s){if(e){var f=!1,p=null,l=function(){if(!f){var e,r,l=t.getState();try{e=n(l,o.current)}catch(e){r=e,p=e}r||(p=null),e===u.current?a.current||c():(u.current=e,i.current=e,a.current=!0,s({type:"STORE_UPDATED",payload:{error:r}}))}};r.onStateChange=l,r.trySubscribe(),l();return function(){if(f=!0,r.tryUnsubscribe(),r.onStateChange=null,p)throw p}}}var H=function(){return[null,0]};function U(e,r){void 0===r&&(r={});var n=r.getDisplayName,u=void 0===n?function(e){return"ConnectAdvanced("+e+")"}:n,a=r.methodName,i=void 0===a?"connectAdvanced":a,c=r.renderCountProp,f=void 0===c?void 0:c,p=r.shouldHandleStateChanges,l=void 0===p||p,m=r.storeKey,b=void 0===m?"store":m,h=r.forwardRef,P=void 0!==h&&h,g=r.context,O=void 0===g?s:g,w=v(r,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef","forwardRef","context"]),C=O;return function(r){var n=r.displayName||r.name||"Component",a=u(n),c=y({},w,{getDisplayName:u,methodName:i,renderCountProp:f,shouldHandleStateChanges:l,storeKey:b,displayName:a,wrappedComponentName:n,WrappedComponent:r}),s=w.pure;var p=s?t.useMemo:function(e){return e()};function m(n){var u=t.useMemo(function(){var e=n.forwardedRef,t=v(n,["forwardedRef"]);return[n.context,e,t]},[n]),a=u[0],i=u[1],s=u[2],f=t.useMemo(function(){return a&&a.Consumer&&S(o.createElement(a.Consumer,null))?a:C},[a,C]),m=t.useContext(f),b=!!n.store&&!!n.store.getState&&!!n.store.dispatch,h=b?n.store:m.store,P=t.useMemo(function(){return function(t){return e(t.dispatch,c)}(h)},[h]),g=t.useMemo(function(){if(!l)return q;var e=new d(h,b?null:m.subscription),t=e.notifyNestedSubs.bind(e);return[e,t]},[h,b,m]),O=g[0],w=g[1],x=t.useMemo(function(){return b?m:y({},m,{subscription:O})},[b,m,O]),E=t.useReducer(D,_,H),M=E[0][0],T=E[1];if(M&&M.error)throw M.error;var R=t.useRef(),$=t.useRef(s),j=t.useRef(),N=t.useRef(!1),U=p(function(){return j.current&&s===$.current?j.current:P(h.getState(),s)},[h,M,s]);k(F,[$,R,N,s,U,j,w]),k(W,[l,h,O,P,$,R,N,j,w,T],[h,O,P]);var A=t.useMemo(function(){return o.createElement(r,y({},U,{ref:i}))},[i,r,U]);return t.useMemo(function(){return l?o.createElement(f.Provider,{value:x},A):A},[f,A,x])}var h=s?o.memo(m):m;if(h.WrappedComponent=r,h.displayName=a,P){var g=o.forwardRef(function(e,t){return o.createElement(h,y({},e,{forwardedRef:t}))});return g.displayName=a,g.WrappedComponent=r,j(g,r)}return j(h,r)}}function A(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function I(e,t){if(A(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(!Object.prototype.hasOwnProperty.call(t,r[n])||!A(e[r[n]],t[r[n]]))return!1;return!0}function L(e){return function(t,r){var n=e(t,r);function o(){return n}return o.dependsOnOwnProps=!1,o}}function z(e){return null!=e.dependsOnOwnProps?!!e.dependsOnOwnProps:1!==e.length}function K(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=z(e);var o=n(t,r);return"function"==typeof o&&(n.mapToProps=o,n.dependsOnOwnProps=z(o),o=n(t,r)),o},n}}var V=[function(e){return"function"==typeof e?K(e):void 0},function(e){return e?void 0:L(function(e){return{dispatch:e}})},function(e){return e&&"object"==typeof e?L(function(t){return r.bindActionCreators(e,t)}):void 0}];var B=[function(e){return"function"==typeof e?K(e):void 0},function(e){return e?void 0:L(function(){return{}})}];function Y(e,t,r){return y({},r,{},e,{},t)}var G=[function(e){return"function"==typeof e?function(e){return function(t,r){var n,o=r.pure,u=r.areMergedPropsEqual,a=!1;return function(t,r,i){var c=e(t,r,i);return a?o&&u(c,n)||(n=c):(a=!0,n=c),n}}}(e):void 0},function(e){return e?void 0:function(){return Y}}];function J(e,t,r,n){return function(o,u){return r(e(o,u),t(n,u),u)}}function Q(e,t,r,n,o){var u,a,i,c,s,f=o.areStatesEqual,p=o.areOwnPropsEqual,l=o.areStatePropsEqual,d=!1;function y(o,d){var y,v,m=!p(d,a),b=!f(o,u);return u=o,a=d,m&&b?(i=e(u,a),t.dependsOnOwnProps&&(c=t(n,a)),s=r(i,c,a)):m?(e.dependsOnOwnProps&&(i=e(u,a)),t.dependsOnOwnProps&&(c=t(n,a)),s=r(i,c,a)):b?(y=e(u,a),v=!l(y,i),i=y,v&&(s=r(i,c,a)),s):s}return function(o,f){return d?y(o,f):(i=e(u=o,a=f),c=t(n,a),s=r(i,c,a),d=!0,s)}}function X(e,t){var r=t.initMapStateToProps,n=t.initMapDispatchToProps,o=t.initMergeProps,u=v(t,["initMapStateToProps","initMapDispatchToProps","initMergeProps"]),a=r(e,u),i=n(e,u),c=o(e,u);return(u.pure?Q:J)(a,i,c,e,u)}function Z(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 ee(e,t){return e===t}function te(e){var t=void 0===e?{}:e,r=t.connectHOC,n=void 0===r?U:r,o=t.mapStateToPropsFactories,u=void 0===o?B:o,a=t.mapDispatchToPropsFactories,i=void 0===a?V:a,c=t.mergePropsFactories,s=void 0===c?G:c,f=t.selectorFactory,p=void 0===f?X:f;return function(e,t,r,o){void 0===o&&(o={});var a=o.pure,c=void 0===a||a,f=o.areStatesEqual,l=void 0===f?ee:f,d=o.areOwnPropsEqual,m=void 0===d?I:d,b=o.areStatePropsEqual,h=void 0===b?I:b,S=o.areMergedPropsEqual,P=void 0===S?I:S,g=v(o,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),O=Z(e,u,"mapStateToProps"),w=Z(t,i,"mapDispatchToProps"),C=Z(r,s,"mergeProps");return n(p,y({methodName:"connect",getDisplayName:function(e){return"Connect("+e+")"},shouldHandleStateChanges:!!e,initMapStateToProps:O,initMapDispatchToProps:w,initMergeProps:C,pure:c,areStatesEqual:l,areOwnPropsEqual:m,areStatePropsEqual:h,areMergedPropsEqual:P},g))}}var re=te();function ne(){return t.useContext(s)}function oe(e){void 0===e&&(e=s);var r=e===s?ne:function(){return t.useContext(e)};return function(){return r().store}}var ue=oe();function ae(e){void 0===e&&(e=s);var t=e===s?ue:oe(e);return function(){return t().dispatch}}var ie=ae(),ce=function(e,t){return e===t};function se(e){void 0===e&&(e=s);var r=e===s?ne:function(){return t.useContext(e)};return function(e,n){void 0===n&&(n=ce);var o=r();return function(e,r,n,o){var u,a=t.useReducer(function(e){return e+1},0)[1],i=t.useMemo(function(){return new d(n,o)},[n,o]),c=t.useRef(),s=t.useRef(),f=t.useRef();try{u=e!==s.current||c.current?e(n.getState()):f.current}catch(e){throw c.current&&(e.message+="\nThe error may be correlated with this previous error:\n"+c.current.stack+"\n\n"),e}return N(function(){s.current=e,f.current=u,c.current=void 0}),N(function(){function e(){try{var e=s.current(n.getState());if(r(e,f.current))return;f.current=e}catch(e){c.current=e}a({})}return i.onStateChange=e,i.trySubscribe(),e(),function(){return i.tryUnsubscribe()}},[n,i]),u}(e,n,o.store,o.subscription)}}var fe=se();f=n.unstable_batchedUpdates,Object.defineProperty(e,"batch",{enumerable:!0,get:function(){return n.unstable_batchedUpdates}}),e.Provider=function(e){var r=e.store,n=e.context,u=e.children,a=t.useMemo(function(){var e=new d(r);return e.onStateChange=e.notifyNestedSubs,{store:r,subscription:e}},[r]),i=t.useMemo(function(){return r.getState()},[r]);return t.useEffect(function(){var e=a.subscription;return e.trySubscribe(),i!==r.getState()&&e.notifyNestedSubs(),function(){e.tryUnsubscribe(),e.onStateChange=null}},[a,i]),o.createElement((n||s).Provider,{value:a},u)},e.ReactReduxContext=s,e.connect=re,e.connectAdvanced=U,e.createDispatchHook=ae,e.createSelectorHook=se,e.createStoreHook=oe,e.shallowEqual=I,e.useDispatch=ie,e.useSelector=fe,e.useStore=ue,Object.defineProperty(e,"__esModule",{value:!0})});
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import hoistStatics from 'hoist-non-react-statics';
import invariant from 'invariant';
import React, { useContext, useMemo, useRef, useReducer } from 'react';

@@ -27,2 +26,98 @@ import { isValidElementType, isContextConsumer } from 'react-is';

function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
useIsomorphicLayoutEffect(function () {
return effectFunc.apply(void 0, effectArgs);
}, dependencies);
}
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs) {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps;
lastChildProps.current = actualChildProps;
renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update
if (childPropsFromStoreUpdate.current) {
childPropsFromStoreUpdate.current = null;
notifyNestedSubs();
}
}
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch) {
// If we're not subscribed to the store, nothing to do here
if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts
var didUnsubscribe = false;
var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component
var checkForUpdates = function checkForUpdates() {
if (didUnsubscribe) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return;
}
var latestStoreState = store.getState();
var newChildProps, error;
try {
// Actually run the selector with the most recent store state and wrapper props
// to determine what the child props should be
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
} catch (e) {
error = e;
lastThrownError = e;
}
if (!error) {
lastThrownError = null;
} // If the child props haven't changed, nothing to do here - cascade the subscription update
if (newChildProps === lastChildProps.current) {
if (!renderIsScheduled.current) {
notifyNestedSubs();
}
} else {
// Save references to the new child props. Note that we track the "child props from store update"
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
// forcing another re-render, which we don't want.
lastChildProps.current = newChildProps;
childPropsFromStoreUpdate.current = newChildProps;
renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
forceComponentUpdateDispatch({
type: 'STORE_UPDATED',
payload: {
error: error
}
});
}
}; // Actually subscribe to the nearest connected ancestor (or store)
subscription.onStateChange = checkForUpdates;
subscription.trySubscribe(); // Pull data from the store after first render in case the store has
// changed since we began.
checkForUpdates();
var unsubscribeWrapper = function unsubscribeWrapper() {
didUnsubscribe = true;
subscription.tryUnsubscribe();
subscription.onStateChange = null;
if (lastThrownError) {
// It's possible that we caught an error due to a bad mapState function, but the
// parent re-rendered without this component and we're about to unmount.
// This shouldn't happen as long as we do top-down subscriptions correctly, but
// if we ever do those wrong, this throw will surface the error in our tests.
// In that case, throw the error from here so it doesn't get lost.
throw lastThrownError;
}
};
return unsubscribeWrapper;
}
var initStateUpdates = function initStateUpdates() {

@@ -74,10 +169,22 @@ return [null, 0];

invariant(renderCountProp === undefined, "renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension");
invariant(!withRef, 'withRef is removed. To access the wrapped instance, use a ref on the connected component');
var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect';
invariant(storeKey === 'store', 'storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
if (process.env.NODE_ENV !== 'production') {
if (renderCountProp !== undefined) {
throw new Error("renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension");
}
if (withRef) {
throw new Error('withRef is removed. To access the wrapped instance, use a ref on the connected component');
}
var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect';
if (storeKey !== 'store') {
throw new Error('storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
}
}
var Context = context;
return function wrapWithConnect(WrappedComponent) {
if (process.env.NODE_ENV !== 'production') {
invariant(isValidElementType(WrappedComponent), "You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
if (process.env.NODE_ENV !== 'production' && !isValidElementType(WrappedComponent)) {
throw new Error("You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
}

@@ -138,4 +245,8 @@

var didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
invariant(didStoreComeFromProps || didStoreComeFromContext, "Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options.")); // Based on the previous check, one of these must be true
if (process.env.NODE_ENV !== 'production' && !didStoreComeFromProps && !didStoreComeFromContext) {
throw new Error("Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options."));
} // Based on the previous check, one of these must be true
var store = didStoreComeFromProps ? props.store : contextValue.store;

@@ -216,91 +327,5 @@ var childPropsSelector = useMemo(function () {

useIsomorphicLayoutEffect(function () {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps;
lastChildProps.current = actualChildProps;
renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs]); // Our re-subscribe logic only runs when the store/subscription setup changes
if (childPropsFromStoreUpdate.current) {
childPropsFromStoreUpdate.current = null;
notifyNestedSubs();
}
}); // Our re-subscribe logic only runs when the store/subscription setup changes
useIsomorphicLayoutEffect(function () {
// If we're not subscribed to the store, nothing to do here
if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts
var didUnsubscribe = false;
var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component
var checkForUpdates = function checkForUpdates() {
if (didUnsubscribe) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return;
}
var latestStoreState = store.getState();
var newChildProps, error;
try {
// Actually run the selector with the most recent store state and wrapper props
// to determine what the child props should be
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
} catch (e) {
error = e;
lastThrownError = e;
}
if (!error) {
lastThrownError = null;
} // If the child props haven't changed, nothing to do here - cascade the subscription update
if (newChildProps === lastChildProps.current) {
if (!renderIsScheduled.current) {
notifyNestedSubs();
}
} else {
// Save references to the new child props. Note that we track the "child props from store update"
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
// forcing another re-render, which we don't want.
lastChildProps.current = newChildProps;
childPropsFromStoreUpdate.current = newChildProps;
renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
forceComponentUpdateDispatch({
type: 'STORE_UPDATED',
payload: {
error: error
}
});
}
}; // Actually subscribe to the nearest connected ancestor (or store)
subscription.onStateChange = checkForUpdates;
subscription.trySubscribe(); // Pull data from the store after first render in case the store has
// changed since we began.
checkForUpdates();
var unsubscribeWrapper = function unsubscribeWrapper() {
didUnsubscribe = true;
subscription.tryUnsubscribe();
subscription.onStateChange = null;
if (lastThrownError) {
// It's possible that we caught an error due to a bad mapState function, but the
// parent re-rendered without this component and we're about to unmount.
// This shouldn't happen as long as we do top-down subscriptions correctly, but
// if we ever do those wrong, this throw will surface the error in our tests.
// In that case, throw the error from here so it doesn't get lost.
throw lastThrownError;
}
};
return unsubscribeWrapper;
}, [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component.
useIsomorphicLayoutEffectWithArgs(subscribeUpdates, [shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch], [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component.
// We memoize the elements for the rendered child component as an optimization.

@@ -307,0 +332,0 @@

import React from 'react';
export var ReactReduxContext = React.createContext(null);
export var ReactReduxContext =
/*#__PURE__*/
React.createContext(null);
if (process.env.NODE_ENV !== 'production') {
ReactReduxContext.displayName = 'ReactRedux';
}
export default ReactReduxContext;

@@ -40,11 +40,14 @@ import React, { useMemo, useEffect } from 'react';

Provider.propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
context: PropTypes.object,
children: PropTypes.any
};
if (process.env.NODE_ENV !== 'production') {
Provider.propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
context: PropTypes.object,
children: PropTypes.any
};
}
export default Provider;

@@ -98,2 +98,4 @@ import _extends from "@babel/runtime/helpers/esm/extends";

}
export default createConnect();
export default
/*#__PURE__*/
createConnect();

@@ -6,3 +6,3 @@ import { ReactReduxContext } from '../components/Context';

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useDispatch` hook bound to the specified context.

@@ -44,2 +44,4 @@ */

export var useDispatch = createDispatchHook();
export var useDispatch =
/*#__PURE__*/
createDispatchHook();
import { useContext } from 'react';
import invariant from 'invariant';
import { ReactReduxContext } from '../components/Context';

@@ -23,4 +22,8 @@ /**

var contextValue = useContext(ReactReduxContext);
invariant(contextValue, 'could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
if (process.env.NODE_ENV !== 'production' && !contextValue) {
throw new Error('could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
}
return contextValue;
}
import { useReducer, useRef, useMemo, useContext } from 'react';
import invariant from 'invariant';
import { useReduxContext as useDefaultReduxContext } from './useReduxContext';

@@ -33,9 +32,7 @@ import Subscription from '../utils/Subscription';

} catch (err) {
var errorMessage = "An error occurred while selecting the store state: " + err.message + ".";
if (latestSubscriptionCallbackError.current) {
errorMessage += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\nOriginal stack trace:";
err.message += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\n";
}
throw new Error(errorMessage);
throw err;
}

@@ -81,3 +78,3 @@

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useSelector` hook bound to the specified context.

@@ -100,3 +97,5 @@ */

invariant(selector, "You must pass a selector to useSelectors");
if (process.env.NODE_ENV !== 'production' && !selector) {
throw new Error("You must pass a selector to useSelectors");
}

@@ -134,2 +133,4 @@ var _useReduxContext = useReduxContext(),

export var useSelector = createSelectorHook();
export var useSelector =
/*#__PURE__*/
createSelectorHook();

@@ -7,3 +7,3 @@ import { useContext } from 'react';

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useStore` hook bound to the specified context.

@@ -43,2 +43,4 @@ */

export var useStore = createStoreHook();
export var useStore =
/*#__PURE__*/
createStoreHook();

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

var hasOwn = Object.prototype.hasOwnProperty;
function is(x, y) {

@@ -23,3 +21,3 @@ if (x === y) {

for (var i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;

@@ -26,0 +24,0 @@ }

@@ -5,3 +5,2 @@ import { getBatch } from './batch'; // encapsulates the subscription logic for connecting a component to the redux store, as

var CLEARED = null;
var nullListeners = {

@@ -12,17 +11,17 @@ notify: function notify() {}

function createListenerCollection() {
var batch = getBatch(); // the current/next pattern is copied from redux's createStore code.
// TODO: refactor+expose that code to be reusable here?
var current = [];
var next = [];
var batch = getBatch();
var first = null;
var last = null;
return {
clear: function clear() {
next = CLEARED;
current = CLEARED;
first = null;
last = null;
},
notify: function notify() {
var listeners = current = next;
batch(function () {
for (var i = 0; i < listeners.length; i++) {
listeners[i]();
var listener = first;
while (listener) {
listener.callback();
listener = listener.next;
}

@@ -32,13 +31,41 @@ });

get: function get() {
return next;
var listeners = [];
var listener = first;
while (listener) {
listeners.push(listener);
listener = listener.next;
}
return listeners;
},
subscribe: function subscribe(listener) {
subscribe: function subscribe(callback) {
var isSubscribed = true;
if (next === current) next = current.slice();
next.push(listener);
var listener = last = {
callback: callback,
next: null,
prev: last
};
if (listener.prev) {
listener.prev.next = listener;
} else {
first = listener;
}
return function unsubscribe() {
if (!isSubscribed || current === CLEARED) return;
if (!isSubscribed || first === null) return;
isSubscribed = false;
if (next === current) next = current.slice();
next.splice(next.indexOf(listener), 1);
if (listener.next) {
listener.next.prev = listener.prev;
} else {
last = listener.prev;
}
if (listener.prev) {
listener.prev.next = listener.next;
} else {
first = listener.next;
}
};

@@ -45,0 +72,0 @@ }

@@ -10,3 +10,2 @@ import { useEffect, useLayoutEffect } from 'react'; // React currently throws a warning when using useLayoutEffect on the server.

var isHopefullyDomEnvironment = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
export var useIsomorphicLayoutEffect = isHopefullyDomEnvironment ? useLayoutEffect : useEffect;
export var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;

@@ -16,4 +16,2 @@ "use strict";

var _invariant = _interopRequireDefault(require("invariant"));
var _react = _interopRequireWildcard(require("react"));

@@ -46,2 +44,98 @@

function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
return effectFunc.apply(void 0, effectArgs);
}, dependencies);
}
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs) {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps;
lastChildProps.current = actualChildProps;
renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update
if (childPropsFromStoreUpdate.current) {
childPropsFromStoreUpdate.current = null;
notifyNestedSubs();
}
}
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch) {
// If we're not subscribed to the store, nothing to do here
if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts
var didUnsubscribe = false;
var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component
var checkForUpdates = function checkForUpdates() {
if (didUnsubscribe) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return;
}
var latestStoreState = store.getState();
var newChildProps, error;
try {
// Actually run the selector with the most recent store state and wrapper props
// to determine what the child props should be
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
} catch (e) {
error = e;
lastThrownError = e;
}
if (!error) {
lastThrownError = null;
} // If the child props haven't changed, nothing to do here - cascade the subscription update
if (newChildProps === lastChildProps.current) {
if (!renderIsScheduled.current) {
notifyNestedSubs();
}
} else {
// Save references to the new child props. Note that we track the "child props from store update"
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
// forcing another re-render, which we don't want.
lastChildProps.current = newChildProps;
childPropsFromStoreUpdate.current = newChildProps;
renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
forceComponentUpdateDispatch({
type: 'STORE_UPDATED',
payload: {
error: error
}
});
}
}; // Actually subscribe to the nearest connected ancestor (or store)
subscription.onStateChange = checkForUpdates;
subscription.trySubscribe(); // Pull data from the store after first render in case the store has
// changed since we began.
checkForUpdates();
var unsubscribeWrapper = function unsubscribeWrapper() {
didUnsubscribe = true;
subscription.tryUnsubscribe();
subscription.onStateChange = null;
if (lastThrownError) {
// It's possible that we caught an error due to a bad mapState function, but the
// parent re-rendered without this component and we're about to unmount.
// This shouldn't happen as long as we do top-down subscriptions correctly, but
// if we ever do those wrong, this throw will surface the error in our tests.
// In that case, throw the error from here so it doesn't get lost.
throw lastThrownError;
}
};
return unsubscribeWrapper;
}
var initStateUpdates = function initStateUpdates() {

@@ -92,10 +186,23 @@ return [null, 0];

connectOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"]);
(0, _invariant["default"])(renderCountProp === undefined, "renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension");
(0, _invariant["default"])(!withRef, 'withRef is removed. To access the wrapped instance, use a ref on the connected component');
var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect';
(0, _invariant["default"])(storeKey === 'store', 'storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
if (process.env.NODE_ENV !== 'production') {
if (renderCountProp !== undefined) {
throw new Error("renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension");
}
if (withRef) {
throw new Error('withRef is removed. To access the wrapped instance, use a ref on the connected component');
}
var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect';
if (storeKey !== 'store') {
throw new Error('storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
}
}
var Context = context;
return function wrapWithConnect(WrappedComponent) {
if (process.env.NODE_ENV !== 'production') {
(0, _invariant["default"])((0, _reactIs.isValidElementType)(WrappedComponent), "You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
if (process.env.NODE_ENV !== 'production' && !(0, _reactIs.isValidElementType)(WrappedComponent)) {
throw new Error("You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
}

@@ -153,4 +260,8 @@

var didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
(0, _invariant["default"])(didStoreComeFromProps || didStoreComeFromContext, "Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options.")); // Based on the previous check, one of these must be true
if (process.env.NODE_ENV !== 'production' && !didStoreComeFromProps && !didStoreComeFromContext) {
throw new Error("Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options."));
} // Based on the previous check, one of these must be true
var store = didStoreComeFromProps ? props.store : contextValue.store;

@@ -231,91 +342,5 @@ var childPropsSelector = (0, _react.useMemo)(function () {

(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps;
lastChildProps.current = actualChildProps;
renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs]); // Our re-subscribe logic only runs when the store/subscription setup changes
if (childPropsFromStoreUpdate.current) {
childPropsFromStoreUpdate.current = null;
notifyNestedSubs();
}
}); // Our re-subscribe logic only runs when the store/subscription setup changes
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
// If we're not subscribed to the store, nothing to do here
if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts
var didUnsubscribe = false;
var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component
var checkForUpdates = function checkForUpdates() {
if (didUnsubscribe) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return;
}
var latestStoreState = store.getState();
var newChildProps, error;
try {
// Actually run the selector with the most recent store state and wrapper props
// to determine what the child props should be
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
} catch (e) {
error = e;
lastThrownError = e;
}
if (!error) {
lastThrownError = null;
} // If the child props haven't changed, nothing to do here - cascade the subscription update
if (newChildProps === lastChildProps.current) {
if (!renderIsScheduled.current) {
notifyNestedSubs();
}
} else {
// Save references to the new child props. Note that we track the "child props from store update"
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
// forcing another re-render, which we don't want.
lastChildProps.current = newChildProps;
childPropsFromStoreUpdate.current = newChildProps;
renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
forceComponentUpdateDispatch({
type: 'STORE_UPDATED',
payload: {
error: error
}
});
}
}; // Actually subscribe to the nearest connected ancestor (or store)
subscription.onStateChange = checkForUpdates;
subscription.trySubscribe(); // Pull data from the store after first render in case the store has
// changed since we began.
checkForUpdates();
var unsubscribeWrapper = function unsubscribeWrapper() {
didUnsubscribe = true;
subscription.tryUnsubscribe();
subscription.onStateChange = null;
if (lastThrownError) {
// It's possible that we caught an error due to a bad mapState function, but the
// parent re-rendered without this component and we're about to unmount.
// This shouldn't happen as long as we do top-down subscriptions correctly, but
// if we ever do those wrong, this throw will surface the error in our tests.
// In that case, throw the error from here so it doesn't get lost.
throw lastThrownError;
}
};
return unsubscribeWrapper;
}, [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component.
useIsomorphicLayoutEffectWithArgs(subscribeUpdates, [shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch], [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component.
// We memoize the elements for the rendered child component as an optimization.

@@ -322,0 +347,0 @@

@@ -10,6 +10,13 @@ "use strict";

var ReactReduxContext = _react["default"].createContext(null);
var ReactReduxContext =
/*#__PURE__*/
_react["default"].createContext(null);
exports.ReactReduxContext = ReactReduxContext;
if (process.env.NODE_ENV !== 'production') {
ReactReduxContext.displayName = 'ReactRedux';
}
var _default = ReactReduxContext;
exports["default"] = _default;

@@ -52,12 +52,15 @@ "use strict";

Provider.propTypes = {
store: _propTypes["default"].shape({
subscribe: _propTypes["default"].func.isRequired,
dispatch: _propTypes["default"].func.isRequired,
getState: _propTypes["default"].func.isRequired
}),
context: _propTypes["default"].object,
children: _propTypes["default"].any
};
if (process.env.NODE_ENV !== 'production') {
Provider.propTypes = {
store: _propTypes["default"].shape({
subscribe: _propTypes["default"].func.isRequired,
dispatch: _propTypes["default"].func.isRequired,
getState: _propTypes["default"].func.isRequired
}),
context: _propTypes["default"].object,
children: _propTypes["default"].any
};
}
var _default = Provider;
exports["default"] = _default;

@@ -113,4 +113,6 @@ "use strict";

var _default = createConnect();
var _default =
/*#__PURE__*/
createConnect();
exports["default"] = _default;

@@ -14,3 +14,3 @@ "use strict";

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useDispatch` hook bound to the specified context.

@@ -52,3 +52,5 @@ */

var useDispatch = createDispatchHook();
var useDispatch =
/*#__PURE__*/
createDispatchHook();
exports.useDispatch = useDispatch;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -10,4 +8,2 @@ exports.useReduxContext = useReduxContext;

var _invariant = _interopRequireDefault(require("invariant"));
var _Context = require("../components/Context");

@@ -33,4 +29,8 @@

var contextValue = (0, _react.useContext)(_Context.ReactReduxContext);
(0, _invariant["default"])(contextValue, 'could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
if (process.env.NODE_ENV !== 'production' && !contextValue) {
throw new Error('could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
}
return contextValue;
}

@@ -11,4 +11,2 @@ "use strict";

var _invariant = _interopRequireDefault(require("invariant"));
var _useReduxContext2 = require("./useReduxContext");

@@ -47,9 +45,7 @@

} catch (err) {
var errorMessage = "An error occurred while selecting the store state: " + err.message + ".";
if (latestSubscriptionCallbackError.current) {
errorMessage += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\nOriginal stack trace:";
err.message += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\n";
}
throw new Error(errorMessage);
throw err;
}

@@ -95,3 +91,3 @@

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useSelector` hook bound to the specified context.

@@ -114,3 +110,5 @@ */

(0, _invariant["default"])(selector, "You must pass a selector to useSelectors");
if (process.env.NODE_ENV !== 'production' && !selector) {
throw new Error("You must pass a selector to useSelectors");
}

@@ -149,3 +147,5 @@ var _useReduxContext = useReduxContext(),

var useSelector = createSelectorHook();
var useSelector =
/*#__PURE__*/
createSelectorHook();
exports.useSelector = useSelector;

@@ -16,3 +16,3 @@ "use strict";

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useStore` hook bound to the specified context.

@@ -52,3 +52,5 @@ */

var useStore = createStoreHook();
var useStore =
/*#__PURE__*/
createStoreHook();
exports.useStore = useStore;

@@ -5,3 +5,2 @@ "use strict";

exports["default"] = shallowEqual;
var hasOwn = Object.prototype.hasOwnProperty;

@@ -28,3 +27,3 @@ function is(x, y) {

for (var i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;

@@ -31,0 +30,0 @@ }

@@ -11,3 +11,2 @@ "use strict";

// ancestor components re-render before descendants
var CLEARED = null;
var nullListeners = {

@@ -18,17 +17,17 @@ notify: function notify() {}

function createListenerCollection() {
var batch = (0, _batch.getBatch)(); // the current/next pattern is copied from redux's createStore code.
// TODO: refactor+expose that code to be reusable here?
var current = [];
var next = [];
var batch = (0, _batch.getBatch)();
var first = null;
var last = null;
return {
clear: function clear() {
next = CLEARED;
current = CLEARED;
first = null;
last = null;
},
notify: function notify() {
var listeners = current = next;
batch(function () {
for (var i = 0; i < listeners.length; i++) {
listeners[i]();
var listener = first;
while (listener) {
listener.callback();
listener = listener.next;
}

@@ -38,13 +37,41 @@ });

get: function get() {
return next;
var listeners = [];
var listener = first;
while (listener) {
listeners.push(listener);
listener = listener.next;
}
return listeners;
},
subscribe: function subscribe(listener) {
subscribe: function subscribe(callback) {
var isSubscribed = true;
if (next === current) next = current.slice();
next.push(listener);
var listener = last = {
callback: callback,
next: null,
prev: last
};
if (listener.prev) {
listener.prev.next = listener;
} else {
first = listener;
}
return function unsubscribe() {
if (!isSubscribed || current === CLEARED) return;
if (!isSubscribed || first === null) return;
isSubscribed = false;
if (next === current) next = current.slice();
next.splice(next.indexOf(listener), 1);
if (listener.next) {
listener.next.prev = listener.prev;
} else {
last = listener.prev;
}
if (listener.prev) {
listener.prev.next = listener.next;
} else {
first = listener.next;
}
};

@@ -51,0 +78,0 @@ }

@@ -16,4 +16,3 @@ "use strict";

// subscription is created and an inconsistent state may be observed
var isHopefullyDomEnvironment = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
var useIsomorphicLayoutEffect = isHopefullyDomEnvironment ? _react.useLayoutEffect : _react.useEffect;
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
{
"name": "react-redux",
"version": "7.1.3",
"version": "7.2.0",
"description": "Official React bindings for Redux",

@@ -53,3 +53,2 @@ "keywords": [

"hoist-non-react-statics": "^3.3.0",
"invariant": "^2.2.4",
"loose-envify": "^1.4.0",

@@ -56,0 +55,0 @@ "prop-types": "^15.7.2",

import hoistStatics from 'hoist-non-react-statics'
import invariant from 'invariant'
import React, { useContext, useMemo, useRef, useReducer } from 'react'

@@ -27,2 +26,127 @@ import { isValidElementType, isContextConsumer } from 'react-is'

function useIsomorphicLayoutEffectWithArgs(
effectFunc,
effectArgs,
dependencies
) {
useIsomorphicLayoutEffect(() => effectFunc(...effectArgs), dependencies)
}
function captureWrapperProps(
lastWrapperProps,
lastChildProps,
renderIsScheduled,
wrapperProps,
actualChildProps,
childPropsFromStoreUpdate,
notifyNestedSubs
) {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps
lastChildProps.current = actualChildProps
renderIsScheduled.current = false
// If the render was from a store update, clear out that reference and cascade the subscriber update
if (childPropsFromStoreUpdate.current) {
childPropsFromStoreUpdate.current = null
notifyNestedSubs()
}
}
function subscribeUpdates(
shouldHandleStateChanges,
store,
subscription,
childPropsSelector,
lastWrapperProps,
lastChildProps,
renderIsScheduled,
childPropsFromStoreUpdate,
notifyNestedSubs,
forceComponentUpdateDispatch
) {
// If we're not subscribed to the store, nothing to do here
if (!shouldHandleStateChanges) return
// Capture values for checking if and when this component unmounts
let didUnsubscribe = false
let lastThrownError = null
// We'll run this callback every time a store subscription update propagates to this component
const checkForUpdates = () => {
if (didUnsubscribe) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return
}
const latestStoreState = store.getState()
let newChildProps, error
try {
// Actually run the selector with the most recent store state and wrapper props
// to determine what the child props should be
newChildProps = childPropsSelector(
latestStoreState,
lastWrapperProps.current
)
} catch (e) {
error = e
lastThrownError = e
}
if (!error) {
lastThrownError = null
}
// If the child props haven't changed, nothing to do here - cascade the subscription update
if (newChildProps === lastChildProps.current) {
if (!renderIsScheduled.current) {
notifyNestedSubs()
}
} else {
// Save references to the new child props. Note that we track the "child props from store update"
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
// forcing another re-render, which we don't want.
lastChildProps.current = newChildProps
childPropsFromStoreUpdate.current = newChildProps
renderIsScheduled.current = true
// If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
forceComponentUpdateDispatch({
type: 'STORE_UPDATED',
payload: {
error
}
})
}
}
// Actually subscribe to the nearest connected ancestor (or store)
subscription.onStateChange = checkForUpdates
subscription.trySubscribe()
// Pull data from the store after first render in case the store has
// changed since we began.
checkForUpdates()
const unsubscribeWrapper = () => {
didUnsubscribe = true
subscription.tryUnsubscribe()
subscription.onStateChange = null
if (lastThrownError) {
// It's possible that we caught an error due to a bad mapState function, but the
// parent re-rendered without this component and we're about to unmount.
// This shouldn't happen as long as we do top-down subscriptions correctly, but
// if we ever do those wrong, this throw will surface the error in our tests.
// In that case, throw the error from here so it doesn't get lost.
throw lastThrownError
}
}
return unsubscribeWrapper
}
const initStateUpdates = () => [null, 0]

@@ -82,30 +206,36 @@

) {
invariant(
renderCountProp === undefined,
`renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension`
)
if (process.env.NODE_ENV !== 'production') {
if (renderCountProp !== undefined) {
throw new Error(
`renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension`
)
}
if (withRef) {
throw new Error(
'withRef is removed. To access the wrapped instance, use a ref on the connected component'
)
}
invariant(
!withRef,
'withRef is removed. To access the wrapped instance, use a ref on the connected component'
)
const customStoreWarningMessage =
'To use a custom Redux store for specific components, create a custom React context with ' +
"React.createContext(), and pass the context object to React Redux's Provider and specific components" +
' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' +
'You may also pass a {context : MyContext} option to connect'
const customStoreWarningMessage =
'To use a custom Redux store for specific components, create a custom React context with ' +
"React.createContext(), and pass the context object to React Redux's Provider and specific components" +
' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' +
'You may also pass a {context : MyContext} option to connect'
if (storeKey !== 'store') {
throw new Error(
'storeKey has been removed and does not do anything. ' +
customStoreWarningMessage
)
}
}
invariant(
storeKey === 'store',
'storeKey has been removed and does not do anything. ' +
customStoreWarningMessage
)
const Context = context
return function wrapWithConnect(WrappedComponent) {
if (process.env.NODE_ENV !== 'production') {
invariant(
isValidElementType(WrappedComponent),
if (
process.env.NODE_ENV !== 'production' &&
!isValidElementType(WrappedComponent)
) {
throw new Error(
`You must pass a component to the function returned by ` +

@@ -178,9 +308,14 @@ `${methodName}. Instead received ${stringifyComponent(

invariant(
didStoreComeFromProps || didStoreComeFromContext,
`Could not find "store" in the context of ` +
`"${displayName}". Either wrap the root component in a <Provider>, ` +
`or pass a custom React context provider to <Provider> and the corresponding ` +
`React context consumer to ${displayName} in connect options.`
)
if (
process.env.NODE_ENV !== 'production' &&
!didStoreComeFromProps &&
!didStoreComeFromContext
) {
throw new Error(
`Could not find "store" in the context of ` +
`"${displayName}". Either wrap the root component in a <Provider>, ` +
`or pass a custom React context provider to <Provider> and the corresponding ` +
`React context consumer to ${displayName} in connect options.`
)
}

@@ -277,101 +412,30 @@ // Based on the previous check, one of these must be true

// just useEffect instead to avoid the warning, since neither will run anyway.
useIsomorphicLayoutEffect(() => {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps
lastChildProps.current = actualChildProps
renderIsScheduled.current = false
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [
lastWrapperProps,
lastChildProps,
renderIsScheduled,
wrapperProps,
actualChildProps,
childPropsFromStoreUpdate,
notifyNestedSubs
])
// If the render was from a store update, clear out that reference and cascade the subscriber update
if (childPropsFromStoreUpdate.current) {
childPropsFromStoreUpdate.current = null
notifyNestedSubs()
}
})
// Our re-subscribe logic only runs when the store/subscription setup changes
useIsomorphicLayoutEffect(() => {
// If we're not subscribed to the store, nothing to do here
if (!shouldHandleStateChanges) return
useIsomorphicLayoutEffectWithArgs(
subscribeUpdates,
[
shouldHandleStateChanges,
store,
subscription,
childPropsSelector,
lastWrapperProps,
lastChildProps,
renderIsScheduled,
childPropsFromStoreUpdate,
notifyNestedSubs,
forceComponentUpdateDispatch
],
[store, subscription, childPropsSelector]
)
// Capture values for checking if and when this component unmounts
let didUnsubscribe = false
let lastThrownError = null
// We'll run this callback every time a store subscription update propagates to this component
const checkForUpdates = () => {
if (didUnsubscribe) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return
}
const latestStoreState = store.getState()
let newChildProps, error
try {
// Actually run the selector with the most recent store state and wrapper props
// to determine what the child props should be
newChildProps = childPropsSelector(
latestStoreState,
lastWrapperProps.current
)
} catch (e) {
error = e
lastThrownError = e
}
if (!error) {
lastThrownError = null
}
// If the child props haven't changed, nothing to do here - cascade the subscription update
if (newChildProps === lastChildProps.current) {
if (!renderIsScheduled.current) {
notifyNestedSubs()
}
} else {
// Save references to the new child props. Note that we track the "child props from store update"
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
// forcing another re-render, which we don't want.
lastChildProps.current = newChildProps
childPropsFromStoreUpdate.current = newChildProps
renderIsScheduled.current = true
// If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
forceComponentUpdateDispatch({
type: 'STORE_UPDATED',
payload: {
error
}
})
}
}
// Actually subscribe to the nearest connected ancestor (or store)
subscription.onStateChange = checkForUpdates
subscription.trySubscribe()
// Pull data from the store after first render in case the store has
// changed since we began.
checkForUpdates()
const unsubscribeWrapper = () => {
didUnsubscribe = true
subscription.tryUnsubscribe()
subscription.onStateChange = null
if (lastThrownError) {
// It's possible that we caught an error due to a bad mapState function, but the
// parent re-rendered without this component and we're about to unmount.
// This shouldn't happen as long as we do top-down subscriptions correctly, but
// if we ever do those wrong, this throw will surface the error in our tests.
// In that case, throw the error from here so it doesn't get lost.
throw lastThrownError
}
}
return unsubscribeWrapper
}, [store, subscription, childPropsSelector])
// Now that all that's done, we can finally try to actually render the child component.

@@ -378,0 +442,0 @@ // We memoize the elements for the rendered child component as an optimization.

import React from 'react'
export const ReactReduxContext = React.createContext(null)
export const ReactReduxContext = /*#__PURE__*/ React.createContext(null)
if (process.env.NODE_ENV !== 'production') {
ReactReduxContext.displayName = 'ReactRedux'
}
export default ReactReduxContext

@@ -36,12 +36,14 @@ import React, { useMemo, useEffect } from 'react'

Provider.propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
context: PropTypes.object,
children: PropTypes.any
if (process.env.NODE_ENV !== 'production') {
Provider.propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
context: PropTypes.object,
children: PropTypes.any
}
}
export default Provider

@@ -104,2 +104,2 @@ import connectAdvanced from '../components/connectAdvanced'

export default createConnect()
export default /*#__PURE__*/ createConnect()

@@ -7,3 +7,3 @@ import { ReactReduxContext } from '../components/Context'

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useDispatch` hook bound to the specified context.

@@ -14,2 +14,3 @@ */

context === ReactReduxContext ? useDefaultStore : createStoreHook(context)
return function useDispatch() {

@@ -42,2 +43,2 @@ const store = useStore()

*/
export const useDispatch = createDispatchHook()
export const useDispatch = /*#__PURE__*/ createDispatchHook()
import { useContext } from 'react'
import invariant from 'invariant'
import { ReactReduxContext } from '../components/Context'

@@ -24,8 +23,9 @@

invariant(
contextValue,
'could not find react-redux context value; please ensure the component is wrapped in a <Provider>'
)
if (process.env.NODE_ENV !== 'production' && !contextValue) {
throw new Error(
'could not find react-redux context value; please ensure the component is wrapped in a <Provider>'
)
}
return contextValue
}
import { useReducer, useRef, useMemo, useContext } from 'react'
import invariant from 'invariant'
import { useReduxContext as useDefaultReduxContext } from './useReduxContext'

@@ -39,9 +38,7 @@ import Subscription from '../utils/Subscription'

} catch (err) {
let errorMessage = `An error occurred while selecting the store state: ${err.message}.`
if (latestSubscriptionCallbackError.current) {
errorMessage += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\nOriginal stack trace:`
err.message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
}
throw new Error(errorMessage)
throw err
}

@@ -90,3 +87,3 @@

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useSelector` hook bound to the specified context.

@@ -100,4 +97,5 @@ */

return function useSelector(selector, equalityFn = refEquality) {
invariant(selector, `You must pass a selector to useSelectors`)
if (process.env.NODE_ENV !== 'production' && !selector) {
throw new Error(`You must pass a selector to useSelectors`)
}
const { store, subscription: contextSub } = useReduxContext()

@@ -137,2 +135,2 @@

*/
export const useSelector = createSelectorHook()
export const useSelector = /*#__PURE__*/ createSelectorHook()

@@ -8,3 +8,3 @@ import { useContext } from 'react'

*
* @param {Function} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useStore` hook bound to the specified context.

@@ -38,2 +38,2 @@ */

*/
export const useStore = createStoreHook()
export const useStore = /*#__PURE__*/ createStoreHook()

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

const hasOwn = Object.prototype.hasOwnProperty
function is(x, y) {

@@ -29,3 +27,6 @@ if (x === y) {

for (let i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
if (
!Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||
!is(objA[keysA[i]], objB[keysA[i]])
) {
return false

@@ -32,0 +33,0 @@ }

@@ -7,3 +7,2 @@ import { getBatch } from './batch'

const CLEARED = null
const nullListeners = { notify() {} }

@@ -13,18 +12,17 @@

const batch = getBatch()
// the current/next pattern is copied from redux's createStore code.
// TODO: refactor+expose that code to be reusable here?
let current = []
let next = []
let first = null
let last = null
return {
clear() {
next = CLEARED
current = CLEARED
first = null
last = null
},
notify() {
const listeners = (current = next)
batch(() => {
for (let i = 0; i < listeners.length; i++) {
listeners[i]()
let listener = first
while (listener) {
listener.callback()
listener = listener.next
}

@@ -35,16 +33,40 @@ })

get() {
return next
let listeners = []
let listener = first
while (listener) {
listeners.push(listener)
listener = listener.next
}
return listeners
},
subscribe(listener) {
subscribe(callback) {
let isSubscribed = true
if (next === current) next = current.slice()
next.push(listener)
let listener = (last = {
callback,
next: null,
prev: last
})
if (listener.prev) {
listener.prev.next = listener
} else {
first = listener
}
return function unsubscribe() {
if (!isSubscribed || current === CLEARED) return
if (!isSubscribed || first === null) return
isSubscribed = false
if (next === current) next = current.slice()
next.splice(next.indexOf(listener), 1)
if (listener.next) {
listener.next.prev = listener.prev
} else {
last = listener.prev
}
if (listener.prev) {
listener.prev.next = listener.next
} else {
first = listener.next
}
}

@@ -51,0 +73,0 @@ }

@@ -12,9 +12,7 @@ import { useEffect, useLayoutEffect } from 'react'

const isHopefullyDomEnvironment =
export const useIsomorphicLayoutEffect =
typeof window !== 'undefined' &&
typeof window.document !== 'undefined' &&
typeof window.document.createElement !== 'undefined'
export const useIsomorphicLayoutEffect = isHopefullyDomEnvironment
? useLayoutEffect
: useEffect
? useLayoutEffect
: useEffect

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc