2017-04-17 100 views
0

我正在處理一個簡單的應用程序,與ES6和babel作出反應。最近我遇到了這個問題。我在這裏使用了react-notifications包:https://github.com/minhtranite/react-notifications反應:如何正確加載組件?

我只是遵循文檔,它工作正常。在反應加載,開發商沒有使用ES6的方式獲得技術的例子https://github.com/cezary/react-loading

現在:我可以import {NotificationContainer, NotificationManager} from 'react-notifications';

導入但後來我試圖用這個工作。我試圖看看JS文件,並在做npm install react-loading後試過這個:

import {Loading} from 'react-loading';但不知何故,這是行不通的。我得到這個:

你可能忘了您的組件從它的定義的文件導出

但我可以看到它的出口。我究竟做錯了什麼?

+1

你應該這樣做:'import從'react-loading'加載;' –

+0

@SaugatAcharya當然!該組件作爲默認導出。謝謝。如果您發佈 – mehulmpt

+0

@AmitTeli,我會接受您的答案。因爲@SaugatAcharaya說沒有必要做'{Loading}'。該組件作爲默認導出。它現在有效 – mehulmpt

回答

3

由於它是單個模塊,因此它會默認導出。你必須這樣做:

import Loading from 'react-loading';