0

I have a complex analytics html page, I have converted most of the elements into react components, most of my elements are organized into two sections top / bottom.

My setup is working, yet, I'm wondering if this is legal / correct way of setting things up?

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';

import TopSection from './components/app';
import BottomSection from './components/app_content';
import reducers from './reducers';

const createStoreWithMiddleware = applyMiddleware()(createStore);

// Top Section 

ReactDOM.render(
  <Provider store={createStoreWithMiddleware(reducers)}>
    <TopSection />
  </Provider>
  , document.querySelector('.top-section'));

// Bottom Section 

ReactDOM.render(
  <Provider store={createStoreWithMiddleware(reducers)}>
    <BottomSection />
  </Provider>
  , document.querySelector('.bottom-section'));
Deano
  • 11,582
  • 18
  • 69
  • 119

1 Answers1

0

You can have multiple store if it is really needed. But it is strongly recommoneded to NOT go with multiple store setups. Single store is always best choice because,

  • it's reliable
  • it's fast
  • debugging is easy

Here are the links, why multiple store setup is not recommended.

redux.js.org

stackoverflow.com

Community
  • 1
  • 1
Thaadikkaaran
  • 5,088
  • 7
  • 37
  • 59