我正在尝试创建一个表单,该表单可以在react-native-elements的帮助下获取用户名和电子邮件地址,但在render函数内部给出错误(不变违规:元素类型无效:预期为字符串(对于内置-in组件)或类/函数(对于复合组件),但得到:未定义。您可能忘记了从定义的文件中导出组件,或者可能混淆了默认导入和命名导入)。
我试图将FormLabel,FormIput和FormValidationMessage放入render函数中的“视图和容器”中,但这给了我一个我无法弄清的错误。
import React from 'react';
import { View, StyleSheet} from "react-native";
import { FormLabel, FormInput, FormValidationMessage } from 'react-native-elements'
export default class UserDetailsInput extends React.Component {
render() {
return (
<View>
<FormLabel>Name</FormLabel>
<FormInput/>
<FormValidationMessage>Error message</FormValidationMessage>
</View>
);
}};
package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject"
},
"dependencies": {
"expo": "^32.0.0",
"native-base": "^2.12.1",
"react": "16.5.0",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-elements": "^1.1.0",
"react-native-otp-inputs": "^3.0.2"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0"
},
"private": true
}
我要求将react-native-elements显示在UI上,类似于docs网站上所示。