I'm trying to adjust react+ react-router+ redux+ redux-simple-routerwithout success. Everything seems to be working fine until I add redux-simple-routerto the mix, after which I get
"[TypeError: Cannot read property 'listen' of undefined]although I am passing a BrowserHistory object.
Here the code is
import React from 'react'
import ReactDOM from 'react-dom'
import { Route, Router, BrowserHistory } from 'react-router';
import HashHistory from 'react-router/lib/HashHistory';
import { compose, combineReducers, applyMiddleware, createStore } from 'redux'
import { Provider } from 'react-redux'
import { syncHistory, routeReducer } from 'redux-simple-router'
import * as reducers from 'reducers/reducers'
import Blank from 'routes/blank';
export default (withHistory, onUpdate) => {
const reducer = combineReducers(Object.assign({}, reducers, {
routing: routeReducer
}));
const reduxRouterMiddleware = syncHistory(BrowserHistory)
const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware)(createStore)
const store = createStoreWithMiddleware(reducer)
return (
<Provider store={store}>
<Router history={BrowserHistory} onUpdate={onUpdate}>
<Route path='/' component={Blank} />
</Router>
</Provider>
);
};
Note. . I just found that I am compiling reactive templates on an express server with renderToString(). That is why it was not identified ??? What am I doing?
Note 2: if instead import BrowserHistory from 'react-router/lib/BrowserHistory'I get
TypeError: history.listen is not a function;
source
share