From 5a721125ff777199d0465c464756595b999a63ed Mon Sep 17 00:00:00 2001 From: Ioan Lucut Date: Wed, 6 Mar 2019 11:54:21 +0100 Subject: [PATCH] ref #133: chore: Use `reduxConnectStore` instead of `store` in the AsyncConnect to avoid possible collisions --- __tests__/redux-connect.spec.js | 2 +- modules/components/AsyncConnect.js | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/__tests__/redux-connect.spec.js b/__tests__/redux-connect.spec.js index c09c77d..ed30794 100644 --- a/__tests__/redux-connect.spec.js +++ b/__tests__/redux-connect.spec.js @@ -15,7 +15,7 @@ import { setToImmutableStateFunc, setToMutableStateFunc } from '../modules/helpe // import module import { endGlobalLoad, beginGlobalLoad } from '../modules/store'; -import AsyncConnectWithContext,{ AsyncConnect } from '../modules/components/AsyncConnect'; +import AsyncConnectWithContext, { AsyncConnect } from '../modules/components/AsyncConnect'; import { asyncConnect, reducer as reduxAsyncConnect, diff --git a/modules/components/AsyncConnect.js b/modules/components/AsyncConnect.js index 34a2667..3a29a5c 100644 --- a/modules/components/AsyncConnect.js +++ b/modules/components/AsyncConnect.js @@ -17,7 +17,7 @@ export class AsyncConnect extends Component { location: PropTypes.object.isRequired, match: PropTypes.object.isRequired, helpers: PropTypes.any, - store: PropTypes.object.isRequired, + reduxConnectStore: PropTypes.object.isRequired, }; static defaultProps = { @@ -66,13 +66,16 @@ export class AsyncConnect extends Component { } isLoaded() { - const { store } = this.props; - return getMutableState(store.getState()).reduxAsyncConnect.loaded; + const { reduxConnectStore } = this.props; + return getMutableState(reduxConnectStore.getState()).reduxAsyncConnect.loaded; } - loadAsyncData(props) { + loadAsyncData({ reduxConnectStore, ...otherProps }) { const { location, beginGlobalLoad, endGlobalLoad } = this.props; - const loadResult = loadAsyncConnect(props); + const loadResult = loadAsyncConnect({ + ...otherProps, + store: reduxConnectStore, + }); this.setState({ previousLocation: location }); @@ -86,7 +89,7 @@ export class AsyncConnect extends Component { // loaded props last time and not the last called route if ( this.loadDataCounter === loadDataCounterOriginal - && this.mounted !== false + && this.mounted !== false ) { this.setState({ previousLocation: null }); } @@ -119,7 +122,12 @@ const AsyncConnectWithContext = ({ context, ...otherProps }) => { return ( - {({ store }) => } + {({ store: reduxConnectStore }) => ( + + )} ); };