3

How can I share a redux store between two or more applications on the same page? (assuming because of the requirements, it's not possible to put the two apps under the same components tree).

import React from 'react';
import ReactDOM from 'react-dom';

import { Provider } from 'react-redux';
import store from './store.js';
import App1 from './App1.js';
import App2 from './App2.js';

ReactDOM.render(
    <Provider store={store}>
        <App1 />
    </Provider>,
    document.querySelector('#app-1')
);

ReactDOM.render(
    <Provider store={store}>
        <App2 />
    </Provider>,
    document.querySelector('#app-2')
);
Stephane
  • 4,978
  • 9
  • 51
  • 86
  • few possible solutions might be found while looking for "redux micro fronted". Like https://stackoverflow.com/questions/62853824/how-to-share-redux-store-in-micro-frontend-architecture but I'm not sure if that's 100% relevant, so not making an official answer – skyboyer Nov 25 '21 at 11:25
  • @skyboyer thank you. I'm checking. – Stephane Nov 25 '21 at 13:16

0 Answers0