react-native - 无法实现react-native-elements表单?

标签 react-native react-native-elements

我正在尝试创建一个表单,它可以在react-native-elements的帮助下获取用户名和电子邮件地址,但它在渲染函数内给出错误(不变违规:元素类型无效:需要一个字符串(用于构建) -in 组件)或类/函数(对于复合组件)但得到:未定义。您可能忘记从定义它的文件中导出组件,或者您可能混淆了默认导入和命名导入。

我尝试将 FormLabel、FormInput 和 FormValidationMessage 放入渲染函数中的 View 和容器内,但它给了我一个我无法弄清楚的错误。

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 required similar to this one
(来源:github.io)

最佳答案

这些组件已在 React Native Elements 1.0 中重命名或删除,因此您的导入会产生 undefined。请查看对应release notes .

关于react-native - 无法实现react-native-elements表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56133847/

相关文章:

android - 我应该如何处理 "implementation method not found"错误?

react-native-elements - 使用 react-native-elements react 原生 - 警告 => 'ListItem.title' prop 已被弃用,将在下一版本中删除

reactjs - react native : FlatList index says is undefined

javascript - create-react-app/react-native-elements 错误

android - 任务 ':app:mergeDebugResources' 执行失败 - AwesomeProject

android - adyen 与 React Native 的集成

javascript - 如何从函数显示 JSX 组件并显示在屏幕上

android - 在项目 ':unimodules-core' 中找不到路径为 ':@unimodules_react-native-adapter' 的项目

react-native - 安装 React-Native-firebase 后无法运行项目