2016-01-27 33 views
3

歷史2.0.0 RC2陣營終極版歷史錯誤 - 類型錯誤:(0,_history2.default)不是一個函數

其次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中導入它,並得到相同的結果。我錯過了什麼?我打開了一個但反對歷史,但他們說我們不看看錯誤,所以請張貼在計算器上。

回答

0

看起來你的npm軟件包history有問題。

嘗試運行npm ls|grep history以查看您安裝的版本。確保你真的使用最新版本(2.0.0-rc2)。

您也可以嘗試刪除node_modules/history並重新安裝。

1

OK - 顯然現在push,replace等都必須從react-router而不是react-router-redux(以前稱爲redux-simple-router)調用。無論如何,自從這些工作之後,我將回到它們的1.x版本。

@Brandon - FYI-我確實有正確的歷史版本。感謝您的建議,但

相關問題