react+ react-router+ redux+をセットアップしようとしましたがredux-simple-router、成功しませんでした。redux-simple-routerミックスに追加するまで、すべてが正常に機能しているように見えます。
"[TypeError: Cannot read property 'listen' of undefined]BrowserHistory オブジェクトを渡していますが。
ここにコードがあります -
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>
);
};
注:を使用して高速サーバーで反応テンプレートをコンパイルしていることを発見しましたrenderToString()。それが定義されていない理由ですか?? 私は何をしますか?
注2:代わりimport BrowserHistory from 'react-router/lib/BrowserHistory'に私が得た場合
TypeError: history.listen is not a function;