Search code examples
reactjsreduxreact-redux

Unusual redux store configuration and protected routes


I need helo about a react-redux project that I using for studying purposes: https://github.com/arshdkhn1/ecommerce-site-template

What I don't understand is how the redux store is provided.

I can see the configureStore.js file but there is no reference to it in the entire project. Am I missing something?

In fact, I need to understand how it is working because I'm trying to create protected route pretty much like this tutorial: https://github.com/Remchi/reddice/blob/master/client/utils/requireAuth.js which creates a high-order component and uses the connect function from react-redux. Unfortunately I get this error:

enter image description here

Probably because of how/where the redux store is configured.

Can someone explain me what is happening, how this store is working and maybe how to create a private route for the project?


Solution

  • The index.js should reference the configureStore.js and have a call like const store = configureStore(); in it before the render call. Something like

    ....
    import configureStore from './path/to/configureStore';
    ....
    ....
    const store = configureStore();
    ReactDOM.render(
       <Prodvider store={store}>
         <App/>
       <Provider>, document.getElementById('root'));