历史2.0.0-rc2
跟随this example逐字和:
import { createHistory } from 'history';
import { applyMiddleware, compose, createStore } from 'redux';
import { syncHistory } from 'react-router-redux';
const history = createHistory(); //<-- ***THIS LINE IS FAILING!!!***
const routingMiddleware = syncHistory(history);
...使用TypeError: (0 , _history2.default) is not a function
创建历史失败。我试过没有{}并尝试从createBrowserHistory导入它也有相同的结果。我错过了什么?我开了一个但反对历史,但是他们说我们不会查看bug,所以请在stackoverflow上发帖。
答案 0 :(得分:1)
好的 - 显然现在必须从react-router而不是react-router-redux(以前称为redux-simple-router)调用push,replace等。无论如何,自从那些工作以来,我将回到它们的1.x版本。
@Brandon - 仅供参考 - 我确实拥有正确的历史版本。感谢您的建议
答案 1 :(得分:0)
history
的npm包看起来有问题。
尝试运行npm ls|grep history
以查看您安装的版本。确保您确实使用的是最新版本(2.0.0-rc2)。
您也可以尝试删除node_modules/history
并重新安装。