我正在开发一个与 ES6 和 babel react 的简单应用程序。最近我遇到了这个问题。我在这里使用了 react-notifications
包:https://github.com/minhtranite/react-notifications
我只是按照文档操作,效果很好。我可以使用 import {NotificationContainer, NotificationManager} from 'react-notifications';
但后来我尝试使用这个:https://github.com/cezary/react-loading
现在在react-loading的例子中,开发者没有使用ES6的方式来获取组件。我尝试查看 JS 文件并在执行 npm install react-loading
后尝试此操作:
import {Loading} from 'react-loading';
但不知何故这不起作用。我明白了:
You likely forgot to export your component from the file it's defined in
但我可以看到它已导出。我做错了什么?
最佳答案
由于它是单个模块,因此默认导出。你必须这样做:
import Loading from 'react-loading';
关于javascript - react : How to load components properly?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43445471/