React + Redux Simple Router: cannot find listening undefined

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;

+4
source share
1 answer

. , : https://github.com/rackt/redux-simple-router/blob/e1df260888d1032d1e68c7694a06b457a4f0130f/README.md

, :

. API- response-router 2.0, 2.0.0-rc5.

:

 history       ^1.17.0  →  ^2.0.0-rc2
 react-router   ^1.0.3  →  ^2.0.0-rc5

... .

+3

Source: https://habr.com/ru/post/1625441/


All Articles