I am trying to create a small project to implement micro-frontend architecture following Micro Frontends article. I am creating multiple repositories for each MFE(Micro frontend) and also using Redux for the application. I have the following architecture:
Frame
- A centralised(main) repo that is responsible for rendering the main application part and MFEs based on routing(I am usingconnected-react-router
). It initialises the Redux store and also adds aninjectReducer
function to dynamically add reducers as explained in code splitting in redux docs. The frame fetches the manifest for particular MFE and renders it. The frame also has some redux data for authentication purpose.MFEs
- These are the individual feature-wise application and are rendered by frame.
Now I have a problem that I want to use injectReducer
function into my MFEs to dynamically add reducers to store. For this, I need access to the same store
instance that is created by frame.
As mentioned in this answer, the ideal way is to export the created store instance and use it but how we can share the same instance of the store across multiple repos?