For those who are experiencing the same problem, I will post my working index.js file (note: I left my custom components and reducers for further guidance).
Now I do not use syncHistoryWithStore . I use the history/createBrowserHistory and create a story for ConnectedRouter. Everything seems to work.
I use Redux DevTools and also used node environments to switch between dev and prod modes.
Obviously, no guarantees are provided.
import React from 'react' import ReactDOM from 'react-dom' import { createStore, combineReducers, applyMiddleware, compose } from 'redux' import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly'; import { Provider } from 'react-redux' import createHistory from 'history/createBrowserHistory' import { Route, Switch } from 'react-router' import { ConnectedRouter, routerReducer, routerMiddleware } from 'react-router-redux' import injectTapEventPlugin from 'react-tap-event-plugin'; import menu from './reducers/menu'; import permissions from './reducers/permissions'; import sitePreferences from './reducers/sitePreferences'; import user from './reducers/user'; // Custom Page Container Imports (these are the visual layout components) import SystemManager from './containers/systemManager/systemManager'; import LoginPage from './containers/pages/login-page/'; import NotFound from './containers/pages/not-found/not-found'; // Create a history of your choosing (we're using a browser history in this case) const history = createHistory() // Build the middleware for intercepting and dispatching navigation actions const middleware = routerMiddleware(history) const isProduction = process.env.NODE_ENV === 'PRODUCTION'; // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = // Redux: Store creation and middleware application based on production/development mode // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = let store = null; if (isProduction === true) { store = createStore( combineReducers({ menu, permissions, sitePreferences, user, routerReducer }), compose(applyMiddleware(middleware)) ); } else { store = createStore( combineReducers({ menu, permissions, sitePreferences, user, routerReducer }), composeWithDevTools(applyMiddleware(middleware)) ); } injectTapEventPlugin(); // Material UI ReactDOM.render( <Provider store={store}> { /* ConnectedRouter will use the store from Provider automatically */ } <ConnectedRouter history={history}> <SystemManager> <Switch> <Route path="/dashboard" component={NotFound} /> <Route path="/login" component={LoginPage} /> </Switch> </ SystemManager> </ConnectedRouter> </Provider>, document.getElementById('app') )
source share