3

我有一个带有react-router-redux. 使用 Webpack 一切都很好。但是,当我将 Bower 与https://cdnjs.cloudflare.com/ajax/libs/react-router-redux/4.0.5/ReactRouterRedux.js(4.0.5 是最新版本,我有react-router2.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')
);

它记录

历史 > {长度:2,状态:对象,滚动恢复:“自动”}

并且您可以看到该属性listen丢失了。

但是,当我进入 的代码时syncHistoryWithStore,返回的对象是一个具有很多属性的对象,包括监听。

对象 { v2_compatible : true, ..., 听}

所以,看起来好像以Object某种方式转换为Symbol( History) 但我不知道为什么以及如何。

4

0 回答 0