简体   繁体   English

React native,元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件),但得到:未定义

[英]React native, Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

I am trying to build my first react native app but i keep getting this error: 我正在尝试构建我的第一个反应本机应用程序,但我不断收到此错误:

"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined" “元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义”

I have searched for an anwser but only saw people who got: "...but got: object" 我搜索了一个答案,但只看到有人得到:“ ...但是得到:对象”

Below is my code: 下面是我的代码:

import React, { Component } from 'react';
import {
      ScrollView,
      Container,
      StyleSheet,
      Button,
      View,
      Label,
      TextInput
    } from 'react-native';

export default class Login extends Component {
  render() {
    return (
        <ScrollView style={styles.scroll}>
            <Container>
                <Button 
                    label="Forgot Login/Pass"
                    styles={{button: styles.alignRight, label: styles.label}} 
                    />
            </Container>
            <Container>
                <Label text="Username or Email" />
                <TextInput
                    style={styles.textInput}
                />
            </Container>
            <Container>
                <Label text="Password" />
                <TextInput
                    secureTextEntry={true}
                    style={styles.textInput}
                />
            </Container>
            <View style={styles.footer}>
                <Container>
                    <Button 
                        label="Sign In"
                        styles={{button: styles.primaryButton, label: styles.buttonWhiteText}} 
                        />
                </Container>
                <Container>
                    <Button 
                        label="CANCEL"
                        styles={{label: styles.buttonBlackText}} 
                        />
                </Container>
            </View>
        </ScrollView>
    );
  }
}
const styles = StyleSheet.create({
    scroll: {
        backgroundColor: '#E1D7D8',
        padding: 30,
        flexDirection: 'column'
    },
    label: {
        color: '#0d8898',
        fontSize: 20
    },
    alignRight: {
        alignSelf: 'flex-end'
    },
    textInput: {
        height: 80,
        fontSize: 30,
        backgroundColor: '#FFF'
    },
    buttonWhiteText: {
        fontSize: 20,
        color: '#FFF',
    },
    buttonBlackText: {
        fontSize: 20,
        color: '#595856'
    },
    primaryButton: {
        backgroundColor: '#34A853'
    },
    footer: {
       marginTop: 100
    }
});

Does somebody know where the problems is? 有人知道问题出在哪里吗?

问题是您要从react-native导入两个名为ContainerLabel组件,这两个组件不存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 元素类型无效:应为字符串(用于内置组件)或类/函数(用于复合组件),但得到:object。 React-Native - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. React-Native React maps 错误预期是字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义 - React maps Error expected a string (for built-in components) or a class/function (for composite components) but got: undefined React Native:期望一个字符串(用于内置组件)或一个类/函数(用于复合组件)但得到:object - React Native: expected a string (for built-in components) or a class/function (for composite components) but got: object 元素类型无效:期望使用字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象 - Element type is invalid:expected a string (for built.in components) or a class/function (for composite components) but got: Object Material Ui - 未捕获错误:不变违规:元素类型无效:预期为字符串(用于内置组件)或类/函数 - Material Ui - Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function React Native 错误:元素类型无效:需要字符串或类/函数,但得到:object - React Native error: Element type is invalid: expected a string or a class/function but got: object 元素类型无效:预期为字符串或类/函数,但得到:对象 - Element type is invalid: expected a string or a class/function but got: object React 本机元素类型无效,应为字符串 - React native element type is invalid expected a string 未捕获的错误:始终违反:元素类型无效:预期为字符串或类/函数,但得到:对象 - Uncaught Error: Invariant Violation: Element type is invalid: expected a string or a class/function but got: object 不变违规:元素类型无效:预期为字符串或类/函数,但获得了:对象。 检查的渲染方法 - Invariant Violation: Element type is invalid: expected a string or a class/function but got: object. Check the render method of
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM