我有一个带react-router-redux
的React / Redux应用。使用Webpack一切都很好。但是,当我使用Bower https://cdnjs.cloudflare.com/ajax/libs/react-router-redux/4.0.5/ReactRouterRedux.js
(4.0.5是最新版本,我有react-router
2.4.1)时,我有以下错误:
history.listen不是函数
这是我的代码
var syncHistoryWithStore = ReactRouterRedux.syncHistoryWithStore;
var browserHistory = ReactRouter.browserHistory;
var history = syncHistoryWithStore(browserHistory, store);
console.log(history);
ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Route path="/" component={App}/>
</Router>
</Provider>,
document.getElementById('root')
);
记录
历史&gt; {length:2,state:Object,scrollRestoration:&#34; auto&#34;}
您可以看到缺少属性listen
。
然而,当我进入syncHistoryWithStore
的代码时,返回的对象是一个具有很多属性的对象,包括listen。
对象{ v2_compatible :true,...,listen}
因此,看起来Object
以某种方式转换为Symbol
(History
),但我不知道原因和方式。