
Handling multiple stores in a React-Redux application
In a React-Redux application, it is good practice to have only one Redux store. But if, for some unusual or special reason, you need more than one store, you will face some problems. The most common problem is that if we wrap a component with a provider and then wrap a child component with another provider, it’s not easy to subscribe to the top-level provider’s store. const Component1 = () => { return ( <Provider store={store1}> <Provider store={store2}> <Component2 /> </Provider> </Provider> ); }; This can become so confusing that, within a few development iterations, you’ll find yourself using providers on every component. Not being able to read values from both stores in a single component will also become frustrating. ...