[英]React Native - “Element type is invalid: expected a string or a class/function but got undefined” - importing custom library?
Alright, I need to hack/tweak this library, so Im trying to import the not transpiled version by downloading the repo and importing: https://github.com/nicotroia/react-native-floating-action-menu#readme好吧,我需要修改/调整这个库,所以我试图通过下载 repo 并导入来导入未转译的版本: https : //github.com/nicotroia/react-native-floating-action-menu#readme
All the paths are correct and the structure of the folder is:所有路径都正确,文件夹结构为:
When I do import { FloatingMenu } from './FloatingMenu/components/FloatingMenu';
当我
import { FloatingMenu } from './FloatingMenu/components/FloatingMenu';
I get the error:我收到错误:
Element type is invalid: expected a string or a class/function but got undefined
元素类型无效:应为字符串或类/函数,但未定义
Says to "Check the render method of App."说“检查应用程序的渲染方法”。 What is wrong here?
这里有什么问题?
Assuming the non-transpiled code you're using is this file , the issue is that it's got a default export, but you're using a named import, not a default import.假设您使用的非转译代码是这个文件,问题是它有一个默认导出,但您使用的是命名导入,而不是默认导入。 The fix is to change this:
解决方法是改变这一点:
import { FloatingMenu } from './FloatingMenu/components/FloatingMenu';
To this:对此:
import FloatingMenu from './FloatingMenu/components/FloatingMenu';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.