Trying to setup redux history so I can redirect
This could be an issue with dependency mismatch. The repository also mentions something regarding this:
This (react-router-redux 5.x) is the version of react-router-redux for use with react-router 4.x. Users of react-router 2.x and 3.x want to use react-router-redux found at the legacy repository.
Here is a working codesandbox set with react-router-redux
5.x and react-router
4.x for the same tutorial.
Update: Seems like you're using react-router-redux
4.x which might be causing the errors. This sandbox uses v4.x and throws errors
If you are not doing a server side rendering then use BrowserRouter instead in your root.js (See above). This is inside package react-router-dom.
import { BrowserRouter } from 'react-router-dom'
I would use ConnectedRouter (from react-router-redux) in root.js file only when I am doing serverside rendering. In this case when Hydrate happens (in index.js) in will not throw errors and warnings.
OR Please try this. Correct your routing with a ConnectedSwitch as shown in below example:
const AppContainer = () => ( <ConnectedSwitch> <Route exact path="/" component={() => (<h1>Home <Link to="/about">About</Link></h1>)} /> <Route path="/about" component={() => (<h1>About <Link to="/">Home</Link></h1>)} /> </ConnectedSwitch> )const App = connect(state => ({ location: state.location,}))(AppContainer)render( <Provider store={store}> <ConnectedRouter history={history}> <App /> </ConnectedRouter> </Provider>, document.getElementById('root'),)
I am open for discussion. Regards.