I wonder if there is possible to have multiple (not related) react-redux components on a single page app with different stores, does anyone know about issues with the provider and the router itself? I am trying to inject state (hydrate redux store with initial state) to componentB from componentA, both components are rendered on a SPA not iframes.
Asked
Active
Viewed 134 times
0
-
What is wrong with having two different reducers instead of two stores? – Shota Sep 23 '16 at 10:47
-
1Usually multiple stores are not a good practice, [here's a bit of explaination](http://stackoverflow.com/questions/33619775/redux-multiple-stores-why-not) – Carlo Sep 23 '16 at 10:47
-
@Shota the components are in different code bases, componentA just allow the user to configure state that can be injected to componentB via an initialization method. – Felix Sep 23 '16 at 10:49
-
Could you clarify further what "different code bases" means? – Shota Sep 23 '16 at 10:51
-
@shota two independent deliverables components. They are not part of the same project. Think of you want to reuse somebody else component in your SPA and the state that that components returns you want to inject that state to your own component in your SPA. ComponentA is that component that it is not yours and componentB you can pass state to it since expose a method to inject initial state, both components are react-redux. – Felix Sep 23 '16 at 10:57
-
You can use combineReducers to "split" the store into separate pieces at the top level. I have used this with multiple teams building different react/redux components. They all go through a single app entry point, so they are all on the same store. You can pass actions/state between them easily by exposing actions and such. – ajmajmajma Sep 23 '16 at 15:26
-
2Possible duplicate of [Keep components between routes using react-router](http://stackoverflow.com/questions/37301044/keep-components-between-routes-using-react-router) – Paul Sweatte Sep 23 '16 at 16:43