简体   繁体   English

React Native - “元素类型无效:需要字符串或类/函数但未定义” - 导入自定义库?

[英]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.

相关问题 React Native 错误:元素类型无效:应为字符串或类/函数,但得到:未定义 - React Native error! Element type is invalid: expected a string or a class/function but got: undefined 世博反应本机元素类型无效:预期为字符串或类/函数,但得到:未定义 - Expo react native Element type is invalid: expected a string or a class/function but got: undefined React Native 错误:元素类型无效:应为字符串或类/函数(对于复合组件)但得到:未定义 - React Native Error: Element type is invalid: expected a string or a class/function (for composite components) but got: undefined React Native Element类型无效,预期字符串但未定义 - React Native Element type is invalid expected a string but got undefined React Native 错误:元素类型无效:应为字符串或类/函数,但得到:未定义。 但是哪里? - React Native Error: Element type is invalid: expected a string or a class/functionbut got: undefined. But where? 元素类型无效:应为字符串或类/函数,但得到:未定义 - Element type is invalid: expected a string or a class/function but got: undefined 简单的 react-spring 组件在 gatsby 中不起作用 - 元素类型无效:预期为字符串或类/函数但得到:未定义 - Simple react-spring component not working in gatsby - Element type is invalid: expected a string or a class/function but got: undefined 反应错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义 - React Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义的 React - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined React React - 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - React - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM