Thess
Thess

Reputation: 93

Setting up redux provider with react admin

I want to wrap my project in a redux store. I do not wish to use it in react admin, only in the rest of my project.

I'm just using the usual redux provider code in my src/index.js file:

ReactDOM.render(
    <Provider store={store}>
        <Router>
            <App />
        </Router>,
    </Provider>,
    document.getElementById("root")
);

which is giving me this error:

Error: Missing history prop.
When integrating react-admin inside an existing redux Provider, you must provide the same 'history' prop to the <Admin> as the one used to bootstrap your routerMiddleware.
React-admin uses this history for its own ConnectedRouter.

I've seen their section about Including React-Admin In Another Redux Application, but I feel like it may be too much for me? First of all, I've never heard of redux-saga before today, second of all, I don't need to dispatch actions from my admin panel so I'm not sure if I would need all this.

I may be in the wrong though.

Is there a simpler way to fix this? Thank you!

Upvotes: 0

Views: 436

Answers (1)

Gildas Garcia
Gildas Garcia

Reputation: 7066

You can separate the two applications, each with their own routes and redux provider.

ReactDOM.render(
    <Router>
        <Switch>
            <Route path="/admin" component={AdminApp} />
            <Route path="/" component={App} />
        <Switch>
    </Router>,
    document.getElementById("root")
);

Then set up the redux Provider in the App component.

Upvotes: 1

Related Questions