W
W
WeReng2018-04-24 00:08:54
React
WeReng, 2018-04-24 00:08:54

How to pass state from Redux Store to ReactDOM.render?

Hello!
Please tell me the best way to pass props to the Load component after receiving the state from the Redux Store. In this case, the isLoading state, which can be either true or false.
The code looks like this:

ReactDOM.render(
  <Provider store={store}>
    <ConnectedRouter history={history}>
      <MainLayout>
        <Load loading={Сюда передаем props true или false}/>
        <Route exact path="/" component={Home}/>
      </MainLayout>
    </ConnectedRouter>
  </Provider>,
  document.getElementById('root')
);

There is an idea in the Load component itself to do connect (mapStateToProps) (Load) and give it the desired state from the store, but I don’t know how correct it will be, I read about smart and dump components and in this case, it seems to me Load should be a dump, In fact, it simply renders the page loading.
I don’t really understand how to use the connect function, if I only have ReactDOM.render, which component to write in brackets connect(mapStateToProps)(component?)
Please help with the code above and, if possible, tell me if it’s the right approach to get data from the store and transfer as props directly in ReactDOM.render or are there any other solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2018-04-24
@WeReng

Do not be afraid of extra connections if this solves your problem. In general, you can simply do<Load loading={store.getState().yourProperty}/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question