supasate / connected-react-router

A Redux binding for React Router v4
MIT License
4.73k stars 592 forks source link

Invariant failed: You should not use <Route> outside a <Router> #547

Closed arianitu closed 2 years ago

arianitu commented 2 years ago

I have ran npm update and installed the latest connected-react-router and now I get this error. I haven't changed any code.

This breaks:

        <ConnectedRouter history={history}>
            <App />
        </ConnectedRouter>

Adding BrowserRouter works (example below), but the install says "Wrap your react-router v4/v5 routing with ConnectedRouter and pass the history object as a prop. Remember to delete any usage of BrowserRouter or NativeRouter as leaving this in will cause problems synchronising the state."

        <ConnectedRouter history={history}>
        <BrowserRouter>
            <App />
       </BrowserRouter>
        </ConnectedRouter>
arianitu commented 2 years ago

My issue was that I was using react-router-dom 5.0.0 and had to upgrade to react-router-dom 5.3.0.

I have no idea why but that fixed the issue.