react-redux
Advanced tools
Comparing version 7.2.4 to 7.2.5
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRedux={},e.React,e.ReactDOM)}(this,(function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t);function u(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},r.exports),r.exports}function a(){}function i(){}i.resetWarningCache=a;u((function(e){e.exports=function(){function e(e,t,r,n,o,u){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==u){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:i,resetWarningCache:a};return r.PropTypes=r,r}()}));var c=o.default.createContext(null);var s=function(e){e()},f=function(){return s},p={notify:function(){}};var l=function(){function e(e,t){this.store=e,this.parentSub=t,this.unsubscribe=null,this.listeners=p,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=f(),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=p)},e}(),d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect;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} | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRedux={},e.React,e.ReactDOM)}(this,(function(e,r,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(r);function u(e,r,t){return e(t={path:r,exports:{},require:function(e,r){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},t.exports),t.exports}function a(){}function c(){}c.resetWarningCache=a;u((function(e){e.exports=function(){function e(e,r,t,n,o,u){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==u){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 r(){return e}e.isRequired=e;var t={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:r,element:e,elementType:e,instanceOf:r,node:e,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:c,resetWarningCache:a};return t.PropTypes=t,t}()}));var i=o.default.createContext(null);var f=function(e){e()},s=function(){return f};var p={notify:function(){},get:function(){return[]}};function l(e,r){var t,n=p;function o(){a.onStateChange&&a.onStateChange()}function u(){t||(t=r?r.addNestedSub(o):e.subscribe(o),n=function(){var e=s(),r=null,t=null;return{clear:function(){r=null,t=null},notify:function(){e((function(){for(var e=r;e;)e.callback(),e=e.next}))},get:function(){for(var e=[],t=r;t;)e.push(t),t=t.next;return e},subscribe:function(e){var n=!0,o=t={callback:e,next:null,prev:t};return o.prev?o.prev.next=o:r=o,function(){n&&null!==r&&(n=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:r=o.next)}}}}())}var a={addNestedSub:function(e){return u(),n.subscribe(e)},notifyNestedSubs:function(){n.notify()},handleChangeWrapper:o,isSubscribed:function(){return!!t},trySubscribe:u,tryUnsubscribe:function(){t&&(t(),t=void 0,n.clear(),n=p)},getListeners:function(){return n}};return a}var d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?r.useLayoutEffect:r.useEffect;function y(){return(y=Object.assign||function(e){for(var r=1;arguments.length>r;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function v(e,r){if(null==e)return{};var t,n,o={},u=Object.keys(e);for(n=0;u.length>n;n++)0>r.indexOf(t=u[n])&&(o[t]=e[t]);return o} | ||
/** @license React v16.13.1 | ||
@@ -9,2 +9,2 @@ * react-is.production.min.js | ||
* LICENSE file in the root directory of this source tree. | ||
*/var m="function"==typeof Symbol&&Symbol.for,b=m?Symbol.for("react.element"):60103,h=m?Symbol.for("react.portal"):60106,S=m?Symbol.for("react.fragment"):60107,P=m?Symbol.for("react.strict_mode"):60108,g=m?Symbol.for("react.profiler"):60114,O=m?Symbol.for("react.provider"):60109,w=m?Symbol.for("react.context"):60110,C=m?Symbol.for("react.async_mode"):60111,x=m?Symbol.for("react.concurrent_mode"):60111,E=m?Symbol.for("react.forward_ref"):60112,T=m?Symbol.for("react.suspense"):60113,M=m?Symbol.for("react.suspense_list"):60120,R=m?Symbol.for("react.memo"):60115,$=m?Symbol.for("react.lazy"):60116,N=m?Symbol.for("react.block"):60121,j=m?Symbol.for("react.fundamental"):60117,q=m?Symbol.for("react.responder"):60118,D=m?Symbol.for("react.scope"):60119;function _(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case b:switch(e=e.type){case C:case x:case S:case g:case P:case T:return e;default:switch(e=e&&e.$$typeof){case w:case E:case $:case R:case O:return e;default:return t}}case h:return t}}}function F(e){return _(e)===x}var k={AsyncMode:C,ConcurrentMode:x,ContextConsumer:w,ContextProvider:O,Element:b,ForwardRef:E,Fragment:S,Lazy:$,Memo:R,Portal:h,Profiler:g,StrictMode:P,Suspense:T,isAsyncMode:function(e){return F(e)||_(e)===C},isConcurrentMode:F,isContextConsumer:function(e){return _(e)===w},isContextProvider:function(e){return _(e)===O},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===b},isForwardRef:function(e){return _(e)===E},isFragment:function(e){return _(e)===S},isLazy:function(e){return _(e)===$},isMemo:function(e){return _(e)===R},isPortal:function(e){return _(e)===h},isProfiler:function(e){return _(e)===g},isStrictMode:function(e){return _(e)===P},isSuspense:function(e){return _(e)===T},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===S||e===x||e===g||e===P||e===T||e===M||"object"==typeof e&&null!==e&&(e.$$typeof===$||e.$$typeof===R||e.$$typeof===O||e.$$typeof===w||e.$$typeof===E||e.$$typeof===j||e.$$typeof===q||e.$$typeof===D||e.$$typeof===N)},typeOf:_},W=u((function(e){e.exports=k})),H={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},U={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},A={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},I={};function L(e){return W.isMemo(e)?A:I[e.$$typeof]||H}I[W.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},I[W.Memo]=A;var z=Object.defineProperty,K=Object.getOwnPropertyNames,V=Object.getOwnPropertySymbols,B=Object.getOwnPropertyDescriptor,Y=Object.getPrototypeOf,G=Object.prototype;var J=function e(t,r,n){if("string"!=typeof r){if(G){var o=Y(r);o&&o!==G&&e(t,o,n)}var u=K(r);V&&(u=u.concat(V(r)));for(var a=L(t),i=L(r),c=0;u.length>c;++c){var s=u[c];if(!(U[s]||n&&n[s]||i&&i[s]||a&&a[s])){var f=B(r,s);try{z(t,s,f)}catch(e){}}}}return t},Q=[],X=[null,null];function Z(e,t){return[t.payload,e[1]+1]}function ee(e,t,r){d((function(){return e.apply(void 0,t)}),r)}function te(e,t,r,n,o,u,a){e.current=n,t.current=o,r.current=!1,u.current&&(u.current=null,a())}function re(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 ne=function(){return[null,0]};function oe(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,s=r.renderCountProp,f=void 0===s?void 0:s,p=r.shouldHandleStateChanges,d=void 0===p||p,m=r.storeKey,b=void 0===m?"store":m,h=r.forwardRef,S=void 0!==h&&h,P=r.context,g=void 0===P?c:P,O=v(r,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef","forwardRef","context"]),w=g;return function(r){var n=r.displayName||r.name||"Component",a=u(n),c=y({},O,{getDisplayName:u,methodName:i,renderCountProp:f,shouldHandleStateChanges:d,storeKey:b,displayName:a,wrappedComponentName:n,WrappedComponent:r}),s=O.pure;var p=s?t.useMemo:function(e){return e()};function m(n){var u=t.useMemo((function(){var e=n.reactReduxForwardedRef,t=v(n,["reactReduxForwardedRef"]);return[n.context,e,t]}),[n]),a=u[0],i=u[1],s=u[2],f=t.useMemo((function(){return a&&a.Consumer&&W.isContextConsumer(o.default.createElement(a.Consumer,null))?a:w}),[a,w]),m=t.useContext(f),b=!!n.store&&!!n.store.getState&&!!n.store.dispatch,h=b?n.store:m.store,S=t.useMemo((function(){return function(t){return e(t.dispatch,c)}(h)}),[h]),P=t.useMemo((function(){if(!d)return X;var e=new l(h,b?null:m.subscription),t=e.notifyNestedSubs.bind(e);return[e,t]}),[h,b,m]),g=P[0],O=P[1],C=t.useMemo((function(){return b?m:y({},m,{subscription:g})}),[b,m,g]),x=t.useReducer(Z,Q,ne),E=x[0][0],T=x[1];if(E&&E.error)throw E.error;var M=t.useRef(),R=t.useRef(s),$=t.useRef(),N=t.useRef(!1),j=p((function(){return $.current&&s===R.current?$.current:S(h.getState(),s)}),[h,E,s]);ee(te,[R,M,N,s,j,$,O]),ee(re,[d,h,g,S,R,M,N,$,O,T],[h,g,S]);var q=t.useMemo((function(){return o.default.createElement(r,y({},j,{ref:i}))}),[i,r,j]);return t.useMemo((function(){return d?o.default.createElement(f.Provider,{value:C},q):q}),[f,q,C])}var h=s?o.default.memo(m):m;if(h.WrappedComponent=r,h.displayName=m.displayName=a,S){var P=o.default.forwardRef((function(e,t){return o.default.createElement(h,y({},e,{reactReduxForwardedRef:t}))}));return P.displayName=a,P.WrappedComponent=r,J(P,r)}return J(h,r)}}function ue(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function ae(e,t){if(ue(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])||!ue(e[r[n]],t[r[n]]))return!1;return!0}function ie(e){return function(t,r){var n=e(t,r);function o(){return n}return o.dependsOnOwnProps=!1,o}}function ce(e){return null!=e.dependsOnOwnProps?!!e.dependsOnOwnProps:1!==e.length}function se(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=ce(e);var o=n(t,r);return"function"==typeof o&&(n.mapToProps=o,n.dependsOnOwnProps=ce(o),o=n(t,r)),o},n}}var fe=[function(e){return"function"==typeof e?se(e):void 0},function(e){return e?void 0:ie((function(e){return{dispatch:e}}))},function(e){return e&&"object"==typeof e?ie((function(t){return function(e,t){var r={},n=function(n){var o=e[n];"function"==typeof o&&(r[n]=function(){return t(o.apply(void 0,arguments))})};for(var o in e)n(o);return r}(e,t)})):void 0}];var pe=[function(e){return"function"==typeof e?se(e):void 0},function(e){return e?void 0:ie((function(){return{}}))}];function le(e,t,r){return y({},r,e,t)}var de=[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 le}}];function ye(e,t,r,n){return function(o,u){return r(e(o,u),t(n,u),u)}}function ve(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 me(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?ve:ye)(a,i,c,e,u)}function be(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 he(e,t){return e===t}function Se(e){var t=void 0===e?{}:e,r=t.connectHOC,n=void 0===r?oe:r,o=t.mapStateToPropsFactories,u=void 0===o?pe:o,a=t.mapDispatchToPropsFactories,i=void 0===a?fe:a,c=t.mergePropsFactories,s=void 0===c?de:c,f=t.selectorFactory,p=void 0===f?me: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?he:f,d=o.areOwnPropsEqual,m=void 0===d?ae:d,b=o.areStatePropsEqual,h=void 0===b?ae:b,S=o.areMergedPropsEqual,P=void 0===S?ae:S,g=v(o,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),O=be(e,u,"mapStateToProps"),w=be(t,i,"mapDispatchToProps"),C=be(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 Pe=Se();function ge(){return t.useContext(c)}function Oe(e){void 0===e&&(e=c);var r=e===c?ge:function(){return t.useContext(e)};return function(){return r().store}}var we=Oe();function Ce(e){void 0===e&&(e=c);var t=e===c?we:Oe(e);return function(){return t().dispatch}}var xe=Ce(),Ee=function(e,t){return e===t};function Te(e){void 0===e&&(e=c);var r=e===c?ge:function(){return t.useContext(e)};return function(e,n){void 0===n&&(n=Ee);var o=r(),u=function(e,r,n,o){var u,a=t.useReducer((function(e){return e+1}),0)[1],i=t.useMemo((function(){return new l(n,o)}),[n,o]),c=t.useRef(),s=t.useRef(),f=t.useRef(),p=t.useRef(),y=n.getState();try{if(e!==s.current||y!==f.current||c.current){var v=e(y);u=void 0!==p.current&&r(v,p.current)?p.current:v}else u=p.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 d((function(){s.current=e,f.current=y,p.current=u,c.current=void 0})),d((function(){function e(){try{var e=n.getState(),t=s.current(e);if(r(t,p.current))return;p.current=t,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);return t.useDebugValue(u),u}}var Me=Te();s=r.unstable_batchedUpdates,Object.defineProperty(e,"batch",{enumerable:!0,get:function(){return r.unstable_batchedUpdates}}),e.Provider=function(e){var r=e.store,n=e.context,u=e.children,a=t.useMemo((function(){var e=new l(r);return e.onStateChange=e.notifyNestedSubs,{store:r,subscription:e}}),[r]),i=t.useMemo((function(){return r.getState()}),[r]);return d((function(){var e=a.subscription;return e.trySubscribe(),i!==r.getState()&&e.notifyNestedSubs(),function(){e.tryUnsubscribe(),e.onStateChange=null}}),[a,i]),o.default.createElement((n||c).Provider,{value:a},u)},e.ReactReduxContext=c,e.connect=Pe,e.connectAdvanced=oe,e.createDispatchHook=Ce,e.createSelectorHook=Te,e.createStoreHook=Oe,e.shallowEqual=ae,e.useDispatch=xe,e.useSelector=Me,e.useStore=we,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/var m="function"==typeof Symbol&&Symbol.for,b=m?Symbol.for("react.element"):60103,h=m?Symbol.for("react.portal"):60106,S=m?Symbol.for("react.fragment"):60107,P=m?Symbol.for("react.strict_mode"):60108,g=m?Symbol.for("react.profiler"):60114,O=m?Symbol.for("react.provider"):60109,w=m?Symbol.for("react.context"):60110,C=m?Symbol.for("react.async_mode"):60111,x=m?Symbol.for("react.concurrent_mode"):60111,E=m?Symbol.for("react.forward_ref"):60112,T=m?Symbol.for("react.suspense"):60113,M=m?Symbol.for("react.suspense_list"):60120,R=m?Symbol.for("react.memo"):60115,$=m?Symbol.for("react.lazy"):60116,N=m?Symbol.for("react.block"):60121,j=m?Symbol.for("react.fundamental"):60117,q=m?Symbol.for("react.responder"):60118,D=m?Symbol.for("react.scope"):60119;function _(e){if("object"==typeof e&&null!==e){var r=e.$$typeof;switch(r){case b:switch(e=e.type){case C:case x:case S:case g:case P:case T:return e;default:switch(e=e&&e.$$typeof){case w:case E:case $:case R:case O:return e;default:return r}}case h:return r}}}function F(e){return _(e)===x}var k={AsyncMode:C,ConcurrentMode:x,ContextConsumer:w,ContextProvider:O,Element:b,ForwardRef:E,Fragment:S,Lazy:$,Memo:R,Portal:h,Profiler:g,StrictMode:P,Suspense:T,isAsyncMode:function(e){return F(e)||_(e)===C},isConcurrentMode:F,isContextConsumer:function(e){return _(e)===w},isContextProvider:function(e){return _(e)===O},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===b},isForwardRef:function(e){return _(e)===E},isFragment:function(e){return _(e)===S},isLazy:function(e){return _(e)===$},isMemo:function(e){return _(e)===R},isPortal:function(e){return _(e)===h},isProfiler:function(e){return _(e)===g},isStrictMode:function(e){return _(e)===P},isSuspense:function(e){return _(e)===T},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===S||e===x||e===g||e===P||e===T||e===M||"object"==typeof e&&null!==e&&(e.$$typeof===$||e.$$typeof===R||e.$$typeof===O||e.$$typeof===w||e.$$typeof===E||e.$$typeof===j||e.$$typeof===q||e.$$typeof===D||e.$$typeof===N)},typeOf:_},H=u((function(e){e.exports=k})),U={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},A={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},W={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},L={};function I(e){return H.isMemo(e)?W:L[e.$$typeof]||U}L[H.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},L[H.Memo]=W;var z=Object.defineProperty,K=Object.getOwnPropertyNames,V=Object.getOwnPropertySymbols,B=Object.getOwnPropertyDescriptor,Y=Object.getPrototypeOf,G=Object.prototype;var J=function e(r,t,n){if("string"!=typeof t){if(G){var o=Y(t);o&&o!==G&&e(r,o,n)}var u=K(t);V&&(u=u.concat(V(t)));for(var a=I(r),c=I(t),i=0;u.length>i;++i){var f=u[i];if(!(A[f]||n&&n[f]||c&&c[f]||a&&a[f])){var s=B(t,f);try{z(r,f,s)}catch(e){}}}}return r},Q=["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef","forwardRef","context"],X=["reactReduxForwardedRef"],Z=[],ee=[null,null];function re(e,r){return[r.payload,e[1]+1]}function te(e,r,t){d((function(){return e.apply(void 0,r)}),t)}function ne(e,r,t,n,o,u,a){e.current=n,r.current=o,t.current=!1,u.current&&(u.current=null,a())}function oe(e,r,t,n,o,u,a,c,i,f){if(e){var s=!1,p=null,l=function(){if(!s){var e,t,l=r.getState();try{e=n(l,o.current)}catch(e){t=e,p=e}t||(p=null),e===u.current?a.current||i():(u.current=e,c.current=e,a.current=!0,f({type:"STORE_UPDATED",payload:{error:t}}))}};t.onStateChange=l,t.trySubscribe(),l();return function(){if(s=!0,t.tryUnsubscribe(),t.onStateChange=null,p)throw p}}}var ue=function(){return[null,0]};function ae(e,t){void 0===t&&(t={});var n=t,u=n.getDisplayName,a=void 0===u?function(e){return"ConnectAdvanced("+e+")"}:u,c=n.methodName,f=void 0===c?"connectAdvanced":c,s=n.renderCountProp,p=void 0===s?void 0:s,d=n.shouldHandleStateChanges,m=void 0===d||d,b=n.storeKey,h=void 0===b?"store":b,S=n.forwardRef,P=void 0!==S&&S,g=n.context,O=void 0===g?i:g,w=v(n,Q),C=O;return function(t){var n=t.displayName||t.name||"Component",u=a(n),c=y({},w,{getDisplayName:a,methodName:f,renderCountProp:p,shouldHandleStateChanges:m,storeKey:h,displayName:u,wrappedComponentName:n,WrappedComponent:t}),i=w.pure;var s=i?r.useMemo:function(e){return e()};function d(n){var u=r.useMemo((function(){var e=n.reactReduxForwardedRef,r=v(n,X);return[n.context,e,r]}),[n]),a=u[0],i=u[1],f=u[2],p=r.useMemo((function(){return a&&a.Consumer&&H.isContextConsumer(o.default.createElement(a.Consumer,null))?a:C}),[a,C]),d=r.useContext(p),b=!!n.store&&!!n.store.getState&&!!n.store.dispatch,h=b?n.store:d.store,S=r.useMemo((function(){return function(r){return e(r.dispatch,c)}(h)}),[h]),P=r.useMemo((function(){if(!m)return ee;var e=l(h,b?null:d.subscription),r=e.notifyNestedSubs.bind(e);return[e,r]}),[h,b,d]),g=P[0],O=P[1],w=r.useMemo((function(){return b?d:y({},d,{subscription:g})}),[b,d,g]),x=r.useReducer(re,Z,ue),E=x[0][0],T=x[1];if(E&&E.error)throw E.error;var M=r.useRef(),R=r.useRef(f),$=r.useRef(),N=r.useRef(!1),j=s((function(){return $.current&&f===R.current?$.current:S(h.getState(),f)}),[h,E,f]);te(ne,[R,M,N,f,j,$,O]),te(oe,[m,h,g,S,R,M,N,$,O,T],[h,g,S]);var q=r.useMemo((function(){return o.default.createElement(t,y({},j,{ref:i}))}),[i,t,j]);return r.useMemo((function(){return m?o.default.createElement(p.Provider,{value:w},q):q}),[p,q,w])}var b=i?o.default.memo(d):d;if(b.WrappedComponent=t,b.displayName=d.displayName=u,P){var S=o.default.forwardRef((function(e,r){return o.default.createElement(b,y({},e,{reactReduxForwardedRef:r}))}));return S.displayName=u,S.WrappedComponent=t,J(S,t)}return J(b,t)}}function ce(e,r){return e===r?0!==e||0!==r||1/e==1/r:e!=e&&r!=r}function ie(e,r){if(ce(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e);if(t.length!==Object.keys(r).length)return!1;for(var n=0;t.length>n;n++)if(!Object.prototype.hasOwnProperty.call(r,t[n])||!ce(e[t[n]],r[t[n]]))return!1;return!0}function fe(e){return function(r,t){var n=e(r,t);function o(){return n}return o.dependsOnOwnProps=!1,o}}function se(e){return null!=e.dependsOnOwnProps?!!e.dependsOnOwnProps:1!==e.length}function pe(e,r){return function(r,t){var n=function(e,r){return n.dependsOnOwnProps?n.mapToProps(e,r):n.mapToProps(e)};return n.dependsOnOwnProps=!0,n.mapToProps=function(r,t){n.mapToProps=e,n.dependsOnOwnProps=se(e);var o=n(r,t);return"function"==typeof o&&(n.mapToProps=o,n.dependsOnOwnProps=se(o),o=n(r,t)),o},n}}var le=[function(e){return"function"==typeof e?pe(e):void 0},function(e){return e?void 0:fe((function(e){return{dispatch:e}}))},function(e){return e&&"object"==typeof e?fe((function(r){return function(e,r){var t={},n=function(n){var o=e[n];"function"==typeof o&&(t[n]=function(){return r(o.apply(void 0,arguments))})};for(var o in e)n(o);return t}(e,r)})):void 0}];var de=[function(e){return"function"==typeof e?pe(e):void 0},function(e){return e?void 0:fe((function(){return{}}))}];function ye(e,r,t){return y({},t,e,r)}var ve=[function(e){return"function"==typeof e?function(e){return function(r,t){var n,o=t.pure,u=t.areMergedPropsEqual,a=!1;return function(r,t,c){var i=e(r,t,c);return a?o&&u(i,n)||(n=i):(a=!0,n=i),n}}}(e):void 0},function(e){return e?void 0:function(){return ye}}],me=["initMapStateToProps","initMapDispatchToProps","initMergeProps"];function be(e,r,t,n){return function(o,u){return t(e(o,u),r(n,u),u)}}function he(e,r,t,n,o){var u,a,c,i,f,s=o.areStatesEqual,p=o.areOwnPropsEqual,l=o.areStatePropsEqual,d=!1;function y(o,d){var y,v,m=!p(d,a),b=!s(o,u);return u=o,a=d,m&&b?(c=e(u,a),r.dependsOnOwnProps&&(i=r(n,a)),f=t(c,i,a)):m?(e.dependsOnOwnProps&&(c=e(u,a)),r.dependsOnOwnProps&&(i=r(n,a)),f=t(c,i,a)):b?(y=e(u,a),v=!l(y,c),c=y,v&&(f=t(c,i,a)),f):f}return function(o,s){return d?y(o,s):(c=e(u=o,a=s),i=r(n,a),f=t(c,i,a),d=!0,f)}}function Se(e,r){var t=r.initMapStateToProps,n=r.initMapDispatchToProps,o=r.initMergeProps,u=v(r,me),a=t(e,u),c=n(e,u),i=o(e,u);return(u.pure?he:be)(a,c,i,e,u)}var Pe=["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"];function ge(e,r,t){for(var n=r.length-1;n>=0;n--){var o=r[n](e);if(o)return o}return function(r,n){throw Error("Invalid value of type "+typeof e+" for "+t+" argument when connecting component "+n.wrappedComponentName+".")}}function Oe(e,r){return e===r}function we(e){var r=void 0===e?{}:e,t=r.connectHOC,n=void 0===t?ae:t,o=r.mapStateToPropsFactories,u=void 0===o?de:o,a=r.mapDispatchToPropsFactories,c=void 0===a?le:a,i=r.mergePropsFactories,f=void 0===i?ve:i,s=r.selectorFactory,p=void 0===s?Se:s;return function(e,r,t,o){void 0===o&&(o={});var a=o.pure,i=void 0===a||a,s=o.areStatesEqual,l=void 0===s?Oe:s,d=o.areOwnPropsEqual,m=void 0===d?ie:d,b=o.areStatePropsEqual,h=void 0===b?ie:b,S=o.areMergedPropsEqual,P=void 0===S?ie:S,g=v(o,Pe),O=ge(e,u,"mapStateToProps"),w=ge(r,c,"mapDispatchToProps"),C=ge(t,f,"mergeProps");return n(p,y({methodName:"connect",getDisplayName:function(e){return"Connect("+e+")"},shouldHandleStateChanges:!!e,initMapStateToProps:O,initMapDispatchToProps:w,initMergeProps:C,pure:i,areStatesEqual:l,areOwnPropsEqual:m,areStatePropsEqual:h,areMergedPropsEqual:P},g))}}var Ce=we();function xe(){return r.useContext(i)}function Ee(e){void 0===e&&(e=i);var t=e===i?xe:function(){return r.useContext(e)};return function(){return t().store}}var Te=Ee();function Me(e){void 0===e&&(e=i);var r=e===i?Te:Ee(e);return function(){return r().dispatch}}var Re=Me(),$e=function(e,r){return e===r};function Ne(e){void 0===e&&(e=i);var t=e===i?xe:function(){return r.useContext(e)};return function(e,n){void 0===n&&(n=$e);var o=t(),u=function(e,t,n,o){var u,a=r.useReducer((function(e){return e+1}),0)[1],c=r.useMemo((function(){return l(n,o)}),[n,o]),i=r.useRef(),f=r.useRef(),s=r.useRef(),p=r.useRef(),y=n.getState();try{if(e!==f.current||y!==s.current||i.current){var v=e(y);u=void 0!==p.current&&t(v,p.current)?p.current:v}else u=p.current}catch(e){throw i.current&&(e.message+="\nThe error may be correlated with this previous error:\n"+i.current.stack+"\n\n"),e}return d((function(){f.current=e,s.current=y,p.current=u,i.current=void 0})),d((function(){function e(){try{var e=n.getState();if(e===s.current)return;var r=f.current(e);if(t(r,p.current))return;p.current=r,s.current=e}catch(e){i.current=e}a()}return c.onStateChange=e,c.trySubscribe(),e(),function(){return c.tryUnsubscribe()}}),[n,c]),u}(e,n,o.store,o.subscription);return r.useDebugValue(u),u}}var je=Ne();f=t.unstable_batchedUpdates,Object.defineProperty(e,"batch",{enumerable:!0,get:function(){return t.unstable_batchedUpdates}}),e.Provider=function(e){var t=e.store,n=e.context,u=e.children,a=r.useMemo((function(){var e=l(t);return e.onStateChange=e.notifyNestedSubs,{store:t,subscription:e}}),[t]),c=r.useMemo((function(){return t.getState()}),[t]);return d((function(){var e=a.subscription;return e.trySubscribe(),c!==t.getState()&&e.notifyNestedSubs(),function(){e.tryUnsubscribe(),e.onStateChange=null}}),[a,c]),o.default.createElement((n||i).Provider,{value:a},u)},e.ReactReduxContext=i,e.connect=Ce,e.connectAdvanced=ae,e.createDispatchHook=Me,e.createSelectorHook=Ne,e.createStoreHook=Ee,e.shallowEqual=ie,e.useDispatch=Re,e.useSelector=je,e.useStore=Te,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,12 +0,6 @@ | ||
import Provider from './components/Provider'; | ||
import connectAdvanced from './components/connectAdvanced'; | ||
import { ReactReduxContext } from './components/Context'; | ||
import connect from './connect/connect'; | ||
import { useDispatch } from './hooks/useDispatch'; | ||
import { useSelector } from './hooks/useSelector'; | ||
import { useStore } from './hooks/useStore'; | ||
import { getBatch } from './utils/batch'; | ||
import shallowEqual from './utils/shallowEqual'; // For other renderers besides ReactDOM and React Native, use the default noop batch function | ||
export * from './exports'; | ||
import { getBatch } from './utils/batch'; // For other renderers besides ReactDOM and React Native, | ||
// use the default noop batch function | ||
var batch = getBatch(); | ||
export { Provider, connectAdvanced, ReactReduxContext, connect, batch, useDispatch, useSelector, useStore, shallowEqual }; | ||
export { batch }; |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
var _excluded = ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"], | ||
_excluded2 = ["reactReduxForwardedRef"]; | ||
import hoistStatics from 'hoist-non-react-statics'; | ||
import React, { useContext, useMemo, useRef, useReducer } from 'react'; | ||
import { isValidElementType, isContextConsumer } from 'react-is'; | ||
import Subscription from '../utils/Subscription'; | ||
import { createSubscription } from '../utils/Subscription'; | ||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'; | ||
@@ -166,3 +168,3 @@ import { ReactReduxContext } from './Context'; // Define some constant arrays just to avoid re-creating these | ||
context = _ref2$context === void 0 ? ReactReduxContext : _ref2$context, | ||
connectOptions = _objectWithoutPropertiesLoose(_ref2, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"]); | ||
connectOptions = _objectWithoutPropertiesLoose(_ref2, _excluded); | ||
@@ -224,3 +226,3 @@ if (process.env.NODE_ENV !== 'production') { | ||
var reactReduxForwardedRef = props.reactReduxForwardedRef, | ||
wrapperProps = _objectWithoutPropertiesLoose(props, ["reactReduxForwardedRef"]); | ||
wrapperProps = _objectWithoutPropertiesLoose(props, _excluded2); | ||
@@ -262,3 +264,5 @@ return [props.context, reactReduxForwardedRef, wrapperProps]; | ||
var subscription = new Subscription(store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in | ||
// This Subscription'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 subscription = createSubscription(store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in | ||
// the middle of the notification loop, where `subscription` will then be null. This can | ||
@@ -268,2 +272,6 @@ // probably be avoided if Subscription's listeners logic is changed to not call listeners | ||
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in | ||
// the middle of the notification loop, where `subscription` will then be null. 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. | ||
var notifyNestedSubs = subscription.notifyNestedSubs.bind(subscription); | ||
@@ -270,0 +278,0 @@ return [subscription, notifyNestedSubs]; |
import React, { useMemo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ReactReduxContext } from './Context'; | ||
import Subscription from '../utils/Subscription'; | ||
import { createSubscription } from '../utils/Subscription'; | ||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'; | ||
@@ -12,3 +12,3 @@ | ||
var contextValue = useMemo(function () { | ||
var subscription = new Subscription(store); | ||
var subscription = createSubscription(store); | ||
subscription.onStateChange = subscription.notifyNestedSubs; | ||
@@ -15,0 +15,0 @@ return { |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
var _excluded = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]; | ||
import connectAdvanced from '../components/connectAdvanced'; | ||
@@ -72,3 +73,3 @@ import shallowEqual from '../utils/shallowEqual'; | ||
areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE, | ||
extraOptions = _objectWithoutPropertiesLoose(_ref3, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]); | ||
extraOptions = _objectWithoutPropertiesLoose(_ref3, _excluded); | ||
@@ -75,0 +76,0 @@ var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); |
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
var _excluded = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]; | ||
import verifySubselectors from './verifySubselectors'; | ||
@@ -75,3 +76,3 @@ export function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) { | ||
initMergeProps = _ref2.initMergeProps, | ||
options = _objectWithoutPropertiesLoose(_ref2, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]); | ||
options = _objectWithoutPropertiesLoose(_ref2, _excluded); | ||
@@ -78,0 +79,0 @@ var mapStateToProps = initMapStateToProps(dispatch, options); |
import { useReducer, useRef, useMemo, useContext, useDebugValue } from 'react'; | ||
import { useReduxContext as useDefaultReduxContext } from './useReduxContext'; | ||
import Subscription from '../utils/Subscription'; | ||
import { createSubscription } from '../utils/Subscription'; | ||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'; | ||
@@ -18,3 +18,3 @@ import { ReactReduxContext } from '../components/Context'; | ||
var subscription = useMemo(function () { | ||
return new Subscription(store, contextSub); | ||
return createSubscription(store, contextSub); | ||
}, [store, contextSub]); | ||
@@ -57,4 +57,8 @@ var latestSubscriptionCallbackError = useRef(); | ||
try { | ||
var newStoreState = store.getState(); | ||
var newStoreState = store.getState(); // Avoid calling selector multiple times if the store's state has not changed | ||
if (newStoreState === latestStoreState.current) { | ||
return; | ||
} | ||
var _newSelectedState = latestSelector.current(newStoreState); | ||
@@ -61,0 +65,0 @@ |
@@ -1,12 +0,7 @@ | ||
import Provider from './components/Provider'; | ||
import connectAdvanced from './components/connectAdvanced'; | ||
import { ReactReduxContext } from './components/Context'; | ||
import connect from './connect/connect'; | ||
import { useDispatch, createDispatchHook } from './hooks/useDispatch'; | ||
import { useSelector, createSelectorHook } from './hooks/useSelector'; | ||
import { useStore, createStoreHook } from './hooks/useStore'; | ||
import { setBatch } from './utils/batch'; | ||
export * from './exports'; | ||
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates'; | ||
import shallowEqual from './utils/shallowEqual'; | ||
import { setBatch } from './utils/batch'; // Enable batched updates in our subscriptions for use | ||
// with standard React renderers (ReactDOM, React Native) | ||
setBatch(batch); | ||
export { Provider, connectAdvanced, ReactReduxContext, connect, batch, useDispatch, createDispatchHook, useSelector, createSelectorHook, useStore, createStoreHook, shallowEqual }; | ||
export { batch }; |
@@ -5,6 +5,2 @@ import { getBatch } from './batch'; // encapsulates the subscription logic for connecting a component to the redux store, as | ||
var nullListeners = { | ||
notify: function notify() {} | ||
}; | ||
function createListenerCollection() { | ||
@@ -74,51 +70,59 @@ var batch = getBatch(); | ||
var Subscription = /*#__PURE__*/function () { | ||
function Subscription(store, parentSub) { | ||
this.store = store; | ||
this.parentSub = parentSub; | ||
this.unsubscribe = null; | ||
this.listeners = nullListeners; | ||
this.handleChangeWrapper = this.handleChangeWrapper.bind(this); | ||
var nullListeners = { | ||
notify: function notify() {}, | ||
get: function get() { | ||
return []; | ||
} | ||
}; | ||
export function createSubscription(store, parentSub) { | ||
var unsubscribe; | ||
var listeners = nullListeners; | ||
var _proto = Subscription.prototype; | ||
function addNestedSub(listener) { | ||
trySubscribe(); | ||
return listeners.subscribe(listener); | ||
} | ||
_proto.addNestedSub = function addNestedSub(listener) { | ||
this.trySubscribe(); | ||
return this.listeners.subscribe(listener); | ||
}; | ||
function notifyNestedSubs() { | ||
listeners.notify(); | ||
} | ||
_proto.notifyNestedSubs = function notifyNestedSubs() { | ||
this.listeners.notify(); | ||
}; | ||
_proto.handleChangeWrapper = function handleChangeWrapper() { | ||
if (this.onStateChange) { | ||
this.onStateChange(); | ||
function handleChangeWrapper() { | ||
if (subscription.onStateChange) { | ||
subscription.onStateChange(); | ||
} | ||
}; | ||
} | ||
_proto.isSubscribed = function isSubscribed() { | ||
return Boolean(this.unsubscribe); | ||
}; | ||
function isSubscribed() { | ||
return Boolean(unsubscribe); | ||
} | ||
_proto.trySubscribe = function trySubscribe() { | ||
if (!this.unsubscribe) { | ||
this.unsubscribe = this.parentSub ? this.parentSub.addNestedSub(this.handleChangeWrapper) : this.store.subscribe(this.handleChangeWrapper); | ||
this.listeners = createListenerCollection(); | ||
function trySubscribe() { | ||
if (!unsubscribe) { | ||
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper); | ||
listeners = createListenerCollection(); | ||
} | ||
}; | ||
} | ||
_proto.tryUnsubscribe = function tryUnsubscribe() { | ||
if (this.unsubscribe) { | ||
this.unsubscribe(); | ||
this.unsubscribe = null; | ||
this.listeners.clear(); | ||
this.listeners = nullListeners; | ||
function tryUnsubscribe() { | ||
if (unsubscribe) { | ||
unsubscribe(); | ||
unsubscribe = undefined; | ||
listeners.clear(); | ||
listeners = nullListeners; | ||
} | ||
} | ||
var subscription = { | ||
addNestedSub: addNestedSub, | ||
notifyNestedSubs: notifyNestedSubs, | ||
handleChangeWrapper: handleChangeWrapper, | ||
isSubscribed: isSubscribed, | ||
trySubscribe: trySubscribe, | ||
tryUnsubscribe: tryUnsubscribe, | ||
getListeners: function getListeners() { | ||
return listeners; | ||
} | ||
}; | ||
return Subscription; | ||
}(); | ||
export { Subscription as default }; | ||
return subscription; | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
batch: true | ||
}; | ||
exports.batch = void 0; | ||
var _Provider = _interopRequireDefault(require("./components/Provider")); | ||
var _exports = require("./exports"); | ||
exports.Provider = _Provider["default"]; | ||
Object.keys(_exports).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _exports[key]) return; | ||
exports[key] = _exports[key]; | ||
}); | ||
var _connectAdvanced = _interopRequireDefault(require("./components/connectAdvanced")); | ||
exports.connectAdvanced = _connectAdvanced["default"]; | ||
var _Context = require("./components/Context"); | ||
exports.ReactReduxContext = _Context.ReactReduxContext; | ||
var _connect = _interopRequireDefault(require("./connect/connect")); | ||
exports.connect = _connect["default"]; | ||
var _useDispatch = require("./hooks/useDispatch"); | ||
exports.useDispatch = _useDispatch.useDispatch; | ||
var _useSelector = require("./hooks/useSelector"); | ||
exports.useSelector = _useSelector.useSelector; | ||
var _useStore = require("./hooks/useStore"); | ||
exports.useStore = _useStore.useStore; | ||
var _batch = require("./utils/batch"); | ||
var _shallowEqual = _interopRequireDefault(require("./utils/shallowEqual")); | ||
exports.shallowEqual = _shallowEqual["default"]; | ||
// For other renderers besides ReactDOM and React Native, use the default noop batch function | ||
// For other renderers besides ReactDOM and React Native, | ||
// use the default noop batch function | ||
var batch = (0, _batch.getBatch)(); | ||
exports.batch = batch; |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -20,3 +18,3 @@ | ||
var _Subscription = _interopRequireDefault(require("../utils/Subscription")); | ||
var _Subscription = require("../utils/Subscription"); | ||
@@ -27,2 +25,9 @@ var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect"); | ||
var _excluded = ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"], | ||
_excluded2 = ["reactReduxForwardedRef"]; | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
// Define some constant arrays just to avoid re-creating these | ||
@@ -185,3 +190,3 @@ var EMPTY_ARRAY = []; | ||
context = _ref2$context === void 0 ? _Context.ReactReduxContext : _ref2$context, | ||
connectOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"]); | ||
connectOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, _excluded); | ||
@@ -241,3 +246,3 @@ if (process.env.NODE_ENV !== 'production') { | ||
var reactReduxForwardedRef = props.reactReduxForwardedRef, | ||
wrapperProps = (0, _objectWithoutPropertiesLoose2["default"])(props, ["reactReduxForwardedRef"]); | ||
wrapperProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded2); | ||
return [props.context, reactReduxForwardedRef, wrapperProps]; | ||
@@ -278,3 +283,5 @@ }, [props]), | ||
var subscription = new _Subscription["default"](store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in | ||
// This Subscription'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 subscription = (0, _Subscription.createSubscription)(store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in | ||
// the middle of the notification loop, where `subscription` will then be null. This can | ||
@@ -284,2 +291,6 @@ // probably be avoided if Subscription's listeners logic is changed to not call listeners | ||
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in | ||
// the middle of the notification loop, where `subscription` will then be null. 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. | ||
var notifyNestedSubs = subscription.notifyNestedSubs.bind(subscription); | ||
@@ -286,0 +297,0 @@ return [subscription, notifyNestedSubs]; |
@@ -5,4 +5,2 @@ "use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
exports.__esModule = true; | ||
@@ -17,6 +15,10 @@ exports["default"] = void 0; | ||
var _Subscription = _interopRequireDefault(require("../utils/Subscription")); | ||
var _Subscription = require("../utils/Subscription"); | ||
var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function Provider(_ref) { | ||
@@ -27,3 +29,3 @@ var store = _ref.store, | ||
var contextValue = (0, _react.useMemo)(function () { | ||
var subscription = new _Subscription["default"](store); | ||
var subscription = (0, _Subscription.createSubscription)(store); | ||
subscription.onStateChange = subscription.notifyNestedSubs; | ||
@@ -30,0 +32,0 @@ return { |
@@ -25,2 +25,4 @@ "use strict"; | ||
var _excluded = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]; | ||
/* | ||
@@ -88,3 +90,3 @@ connect is a facade over connectAdvanced. It turns its args into a compatible | ||
areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? _shallowEqual["default"] : _ref3$areMergedPropsE, | ||
extraOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref3, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]); | ||
extraOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref3, _excluded); | ||
var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); | ||
@@ -91,0 +93,0 @@ var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps'); |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _excluded = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]; | ||
function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) { | ||
@@ -89,3 +91,3 @@ return function impureFinalPropsSelector(state, ownProps) { | ||
initMergeProps = _ref2.initMergeProps, | ||
options = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]); | ||
options = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, _excluded); | ||
var mapStateToProps = initMapStateToProps(dispatch, options); | ||
@@ -92,0 +94,0 @@ var mapDispatchToProps = initMapDispatchToProps(dispatch, options); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
@@ -13,3 +11,3 @@ exports.createSelectorHook = createSelectorHook; | ||
var _Subscription = _interopRequireDefault(require("../utils/Subscription")); | ||
var _Subscription = require("../utils/Subscription"); | ||
@@ -31,3 +29,3 @@ var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect"); | ||
var subscription = (0, _react.useMemo)(function () { | ||
return new _Subscription["default"](store, contextSub); | ||
return (0, _Subscription.createSubscription)(store, contextSub); | ||
}, [store, contextSub]); | ||
@@ -70,4 +68,8 @@ var latestSubscriptionCallbackError = (0, _react.useRef)(); | ||
try { | ||
var newStoreState = store.getState(); | ||
var newStoreState = store.getState(); // Avoid calling selector multiple times if the store's state has not changed | ||
if (newStoreState === latestStoreState.current) { | ||
return; | ||
} | ||
var _newSelectedState = latestSelector.current(newStoreState); | ||
@@ -74,0 +76,0 @@ |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
batch: true | ||
}; | ||
var _Provider = _interopRequireDefault(require("./components/Provider")); | ||
var _exports = require("./exports"); | ||
exports.Provider = _Provider["default"]; | ||
Object.keys(_exports).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _exports[key]) return; | ||
exports[key] = _exports[key]; | ||
}); | ||
var _connectAdvanced = _interopRequireDefault(require("./components/connectAdvanced")); | ||
exports.connectAdvanced = _connectAdvanced["default"]; | ||
var _Context = require("./components/Context"); | ||
exports.ReactReduxContext = _Context.ReactReduxContext; | ||
var _connect = _interopRequireDefault(require("./connect/connect")); | ||
exports.connect = _connect["default"]; | ||
var _useDispatch = require("./hooks/useDispatch"); | ||
exports.useDispatch = _useDispatch.useDispatch; | ||
exports.createDispatchHook = _useDispatch.createDispatchHook; | ||
var _useSelector = require("./hooks/useSelector"); | ||
exports.useSelector = _useSelector.useSelector; | ||
exports.createSelectorHook = _useSelector.createSelectorHook; | ||
var _useStore = require("./hooks/useStore"); | ||
exports.useStore = _useStore.useStore; | ||
exports.createStoreHook = _useStore.createStoreHook; | ||
var _batch = require("./utils/batch"); | ||
var _reactBatchedUpdates = require("./utils/reactBatchedUpdates"); | ||
@@ -44,5 +21,6 @@ | ||
var _shallowEqual = _interopRequireDefault(require("./utils/shallowEqual")); | ||
var _batch = require("./utils/batch"); | ||
exports.shallowEqual = _shallowEqual["default"]; | ||
// Enable batched updates in our subscriptions for use | ||
// with standard React renderers (ReactDOM, React Native) | ||
(0, _batch.setBatch)(_reactBatchedUpdates.unstable_batchedUpdates); |
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
exports.createSubscription = createSubscription; | ||
@@ -11,6 +11,2 @@ var _batch = require("./batch"); | ||
// ancestor components re-render before descendants | ||
var nullListeners = { | ||
notify: function notify() {} | ||
}; | ||
function createListenerCollection() { | ||
@@ -80,51 +76,60 @@ var batch = (0, _batch.getBatch)(); | ||
var Subscription = /*#__PURE__*/function () { | ||
function Subscription(store, parentSub) { | ||
this.store = store; | ||
this.parentSub = parentSub; | ||
this.unsubscribe = null; | ||
this.listeners = nullListeners; | ||
this.handleChangeWrapper = this.handleChangeWrapper.bind(this); | ||
var nullListeners = { | ||
notify: function notify() {}, | ||
get: function get() { | ||
return []; | ||
} | ||
}; | ||
var _proto = Subscription.prototype; | ||
function createSubscription(store, parentSub) { | ||
var unsubscribe; | ||
var listeners = nullListeners; | ||
_proto.addNestedSub = function addNestedSub(listener) { | ||
this.trySubscribe(); | ||
return this.listeners.subscribe(listener); | ||
}; | ||
function addNestedSub(listener) { | ||
trySubscribe(); | ||
return listeners.subscribe(listener); | ||
} | ||
_proto.notifyNestedSubs = function notifyNestedSubs() { | ||
this.listeners.notify(); | ||
}; | ||
function notifyNestedSubs() { | ||
listeners.notify(); | ||
} | ||
_proto.handleChangeWrapper = function handleChangeWrapper() { | ||
if (this.onStateChange) { | ||
this.onStateChange(); | ||
function handleChangeWrapper() { | ||
if (subscription.onStateChange) { | ||
subscription.onStateChange(); | ||
} | ||
}; | ||
} | ||
_proto.isSubscribed = function isSubscribed() { | ||
return Boolean(this.unsubscribe); | ||
}; | ||
function isSubscribed() { | ||
return Boolean(unsubscribe); | ||
} | ||
_proto.trySubscribe = function trySubscribe() { | ||
if (!this.unsubscribe) { | ||
this.unsubscribe = this.parentSub ? this.parentSub.addNestedSub(this.handleChangeWrapper) : this.store.subscribe(this.handleChangeWrapper); | ||
this.listeners = createListenerCollection(); | ||
function trySubscribe() { | ||
if (!unsubscribe) { | ||
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper); | ||
listeners = createListenerCollection(); | ||
} | ||
}; | ||
} | ||
_proto.tryUnsubscribe = function tryUnsubscribe() { | ||
if (this.unsubscribe) { | ||
this.unsubscribe(); | ||
this.unsubscribe = null; | ||
this.listeners.clear(); | ||
this.listeners = nullListeners; | ||
function tryUnsubscribe() { | ||
if (unsubscribe) { | ||
unsubscribe(); | ||
unsubscribe = undefined; | ||
listeners.clear(); | ||
listeners = nullListeners; | ||
} | ||
} | ||
var subscription = { | ||
addNestedSub: addNestedSub, | ||
notifyNestedSubs: notifyNestedSubs, | ||
handleChangeWrapper: handleChangeWrapper, | ||
isSubscribed: isSubscribed, | ||
trySubscribe: trySubscribe, | ||
tryUnsubscribe: tryUnsubscribe, | ||
getListeners: function getListeners() { | ||
return listeners; | ||
} | ||
}; | ||
return Subscription; | ||
}(); | ||
exports["default"] = Subscription; | ||
return subscription; | ||
} |
{ | ||
"name": "react-redux", | ||
"version": "7.2.4", | ||
"version": "7.2.5", | ||
"description": "Official React bindings for Redux", | ||
@@ -29,11 +29,14 @@ "keywords": [ | ||
"build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/react-redux.min.js", | ||
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min", | ||
"build": "yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:umd:min", | ||
"clean": "rimraf lib dist es coverage", | ||
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" index.d.ts \"docs/**/*.md\"", | ||
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" \"docs/**/*.md\"", | ||
"lint": "eslint src test/utils test/components test/hooks", | ||
"prepare": "npm run clean && npm run build", | ||
"pretest": "npm run lint", | ||
"prepare": "yarn clean && yarn build", | ||
"pretest": "yarn lint", | ||
"test": "jest", | ||
"coverage": "codecov" | ||
}, | ||
"workspaces": [ | ||
"website" | ||
], | ||
"peerDependencies": { | ||
@@ -73,3 +76,3 @@ "react": "^16.8.3 || ^17" | ||
"@testing-library/jest-native": "^3.4.3", | ||
"@testing-library/react": "^11.1.0", | ||
"@testing-library/react": "^12.0.0", | ||
"@testing-library/react-hooks": "^3.4.2", | ||
@@ -93,3 +96,3 @@ "@testing-library/react-native": "^7.1.0", | ||
"react-dom": "^16.14.0", | ||
"react-native": "^0.63.3", | ||
"react-native": "^0.64.1", | ||
"react-test-renderer": "^16.14.0", | ||
@@ -96,0 +99,0 @@ "redux": "^4.0.5", |
@@ -1,3 +0,2 @@ | ||
React Redux | ||
========================= | ||
# React Redux | ||
@@ -7,7 +6,6 @@ Official React bindings for [Redux](https://github.com/reduxjs/redux). | ||
[![build status](https://img.shields.io/travis/reduxjs/react-redux/master.svg?style=flat-square)](https://travis-ci.org/reduxjs/react-redux) [![npm version](https://img.shields.io/npm/v/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux) | ||
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/reduxjs/react-redux/CI?style=flat-square) [![npm version](https://img.shields.io/npm/v/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux) | ||
[![npm downloads](https://img.shields.io/npm/dm/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux) | ||
[![redux channel on discord](https://img.shields.io/badge/discord-redux@reactiflux-61DAFB.svg?style=flat-square)](http://www.reactiflux.com) | ||
## Installation | ||
@@ -39,8 +37,8 @@ | ||
This assumes that you’re using [npm](http://npmjs.com/) package manager | ||
with a module bundler like [Webpack](https://webpack.js.org/) or | ||
[Browserify](http://browserify.org/) to consume [CommonJS | ||
This assumes that you’re using [npm](http://npmjs.com/) package manager | ||
with a module bundler like [Webpack](https://webpack.js.org/) or | ||
[Browserify](http://browserify.org/) to consume [CommonJS | ||
modules](https://webpack.js.org/api/module-methods/#commonjs). | ||
If you don’t yet use [npm](http://npmjs.com/) or a modern module bundler, and would rather prefer a single-file [UMD](https://github.com/umdjs/umd) build that makes `ReactRedux` available as a global object, you can grab a pre-built version from [cdnjs](https://cdnjs.com/libraries/react-redux). We *don’t* recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on [npm](http://npmjs.com/). | ||
If you don’t yet use [npm](http://npmjs.com/) or a modern module bundler, and would rather prefer a single-file [UMD](https://github.com/umdjs/umd) build that makes `ReactRedux` available as a global object, you can grab a pre-built version from [cdnjs](https://cdnjs.com/libraries/react-redux). We _don’t_ recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on [npm](http://npmjs.com/). | ||
@@ -51,3 +49,2 @@ ## React Native | ||
## Documentation | ||
@@ -61,5 +58,5 @@ | ||
We do a deep dive on how React Redux works in [this readthesource episode](https://www.youtube.com/watch?v=VJ38wSFbM3A). | ||
We do a deep dive on how React Redux works in [this readthesource episode](https://www.youtube.com/watch?v=VJ38wSFbM3A). | ||
Also, the post [The History and Implementation of React-Redux](https://blog.isquaredsoftware.com/2018/11/react-redux-history-implementation/) | ||
Also, the post [The History and Implementation of React-Redux](https://blog.isquaredsoftware.com/2018/11/react-redux-history-implementation/) | ||
explains what it does, how it works, and how the API and implementation have evolved over time. | ||
@@ -66,0 +63,0 @@ |
@@ -1,26 +0,9 @@ | ||
import Provider from './components/Provider' | ||
import connectAdvanced from './components/connectAdvanced' | ||
import { ReactReduxContext } from './components/Context' | ||
import connect from './connect/connect' | ||
export * from './exports' | ||
import { useDispatch } from './hooks/useDispatch' | ||
import { useSelector } from './hooks/useSelector' | ||
import { useStore } from './hooks/useStore' | ||
import { getBatch } from './utils/batch' | ||
import shallowEqual from './utils/shallowEqual' | ||
// For other renderers besides ReactDOM and React Native, use the default noop batch function | ||
// For other renderers besides ReactDOM and React Native, | ||
// use the default noop batch function | ||
const batch = getBatch() | ||
export { | ||
Provider, | ||
connectAdvanced, | ||
ReactReduxContext, | ||
connect, | ||
batch, | ||
useDispatch, | ||
useSelector, | ||
useStore, | ||
shallowEqual, | ||
} | ||
export { batch } |
import hoistStatics from 'hoist-non-react-statics' | ||
import React, { useContext, useMemo, useRef, useReducer } from 'react' | ||
import { isValidElementType, isContextConsumer } from 'react-is' | ||
import Subscription from '../utils/Subscription' | ||
import { createSubscription } from '../utils/Subscription' | ||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect' | ||
@@ -337,3 +337,3 @@ | ||
// connected to the store via props shouldn't use subscription from context, or vice versa. | ||
const subscription = new Subscription( | ||
const subscription = createSubscription( | ||
store, | ||
@@ -340,0 +340,0 @@ didStoreComeFromProps ? null : contextValue.subscription |
import React, { useMemo } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { ReactReduxContext } from './Context' | ||
import Subscription from '../utils/Subscription' | ||
import { createSubscription } from '../utils/Subscription' | ||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect' | ||
@@ -9,3 +9,3 @@ | ||
const contextValue = useMemo(() => { | ||
const subscription = new Subscription(store) | ||
const subscription = createSubscription(store) | ||
subscription.onStateChange = subscription.notifyNestedSubs | ||
@@ -12,0 +12,0 @@ return { |
import { useReducer, useRef, useMemo, useContext, useDebugValue } from 'react' | ||
import { useReduxContext as useDefaultReduxContext } from './useReduxContext' | ||
import Subscription from '../utils/Subscription' | ||
import { createSubscription } from '../utils/Subscription' | ||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect' | ||
@@ -17,3 +17,3 @@ import { ReactReduxContext } from '../components/Context' | ||
const subscription = useMemo(() => new Subscription(store, contextSub), [ | ||
const subscription = useMemo(() => createSubscription(store, contextSub), [ | ||
store, | ||
@@ -69,2 +69,7 @@ contextSub, | ||
const newStoreState = store.getState() | ||
// Avoid calling selector multiple times if the store's state has not changed | ||
if (newStoreState === latestStoreState.current) { | ||
return | ||
} | ||
const newSelectedState = latestSelector.current(newStoreState) | ||
@@ -71,0 +76,0 @@ |
@@ -1,29 +0,10 @@ | ||
import Provider from './components/Provider' | ||
import connectAdvanced from './components/connectAdvanced' | ||
import { ReactReduxContext } from './components/Context' | ||
import connect from './connect/connect' | ||
export * from './exports' | ||
import { useDispatch, createDispatchHook } from './hooks/useDispatch' | ||
import { useSelector, createSelectorHook } from './hooks/useSelector' | ||
import { useStore, createStoreHook } from './hooks/useStore' | ||
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates' | ||
import { setBatch } from './utils/batch' | ||
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates' | ||
import shallowEqual from './utils/shallowEqual' | ||
// Enable batched updates in our subscriptions for use | ||
// with standard React renderers (ReactDOM, React Native) | ||
setBatch(batch) | ||
export { | ||
Provider, | ||
connectAdvanced, | ||
ReactReduxContext, | ||
connect, | ||
batch, | ||
useDispatch, | ||
createDispatchHook, | ||
useSelector, | ||
createSelectorHook, | ||
useStore, | ||
createStoreHook, | ||
shallowEqual, | ||
} | ||
export { batch } |
@@ -7,4 +7,2 @@ import { getBatch } from './batch' | ||
const nullListeners = { notify() {} } | ||
function createListenerCollection() { | ||
@@ -75,49 +73,60 @@ const batch = getBatch() | ||
export default class Subscription { | ||
constructor(store, parentSub) { | ||
this.store = store | ||
this.parentSub = parentSub | ||
this.unsubscribe = null | ||
this.listeners = nullListeners | ||
const nullListeners = { | ||
notify() {}, | ||
get: () => [], | ||
} | ||
this.handleChangeWrapper = this.handleChangeWrapper.bind(this) | ||
} | ||
export function createSubscription(store, parentSub) { | ||
let unsubscribe | ||
let listeners = nullListeners | ||
addNestedSub(listener) { | ||
this.trySubscribe() | ||
return this.listeners.subscribe(listener) | ||
function addNestedSub(listener) { | ||
trySubscribe() | ||
return listeners.subscribe(listener) | ||
} | ||
notifyNestedSubs() { | ||
this.listeners.notify() | ||
function notifyNestedSubs() { | ||
listeners.notify() | ||
} | ||
handleChangeWrapper() { | ||
if (this.onStateChange) { | ||
this.onStateChange() | ||
function handleChangeWrapper() { | ||
if (subscription.onStateChange) { | ||
subscription.onStateChange() | ||
} | ||
} | ||
isSubscribed() { | ||
return Boolean(this.unsubscribe) | ||
function isSubscribed() { | ||
return Boolean(unsubscribe) | ||
} | ||
trySubscribe() { | ||
if (!this.unsubscribe) { | ||
this.unsubscribe = this.parentSub | ||
? this.parentSub.addNestedSub(this.handleChangeWrapper) | ||
: this.store.subscribe(this.handleChangeWrapper) | ||
function trySubscribe() { | ||
if (!unsubscribe) { | ||
unsubscribe = parentSub | ||
? parentSub.addNestedSub(handleChangeWrapper) | ||
: store.subscribe(handleChangeWrapper) | ||
this.listeners = createListenerCollection() | ||
listeners = createListenerCollection() | ||
} | ||
} | ||
tryUnsubscribe() { | ||
if (this.unsubscribe) { | ||
this.unsubscribe() | ||
this.unsubscribe = null | ||
this.listeners.clear() | ||
this.listeners = nullListeners | ||
function tryUnsubscribe() { | ||
if (unsubscribe) { | ||
unsubscribe() | ||
unsubscribe = undefined | ||
listeners.clear() | ||
listeners = nullListeners | ||
} | ||
} | ||
const subscription = { | ||
addNestedSub, | ||
notifyNestedSubs, | ||
handleChangeWrapper, | ||
isSubscribed, | ||
trySubscribe, | ||
tryUnsubscribe, | ||
getListeners: () => listeners, | ||
} | ||
return subscription | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
281242
90
5857
65