javascript–React native– 对象无效作为React子对象(找到:具有键{$$typeof,type,key,ref,props,_owner,_store}的对象)

javascript–React native– 对象无效作为React子对象(找到:具有键{$$typeof,type,key,ref,props,_owner,_store}的对象),第1张

概述我是ReactNative的新手,我在下面引用了一个错误:ObjectsarenotvalidasaReactchild(found:objectwithkeys{$$typeof,type,key,ref,props,_owner,_store}).Ifyoumeanttorenderacollectionofchildren,useanarrayinstead.这是我的整个代码包含在组

我是React Native的新手,我在下面引用了一个错误:

Objects are not valID as a React child (found: object with keys {$$typeof, type, key, ref, props, _owner, _store}). If you meant to render a collection of children, use an array instead.

这是我的整个代码包含在组件文件中,除了样式:

import React, { Component } from 'react';import { VIEw, Text, Textinput, touchableOpacity, Image, StyleSheet } from 'react-native';import firebase from 'firebase';class LoginForm extends Component {    state = { email: '', password: '', error: '', loading: false };    onbuttonPress(){        const email = this.state.email;        const password = this.state.password;        this.setState({error: '', loading: true});        firebase.auth().signInWithEmailAndPassword(email, password)            .then(this.onLoginSuccess.bind(this))            .catch(() => {                firebase.auth().@R_403_3640@WithEmailAndPassword(email, password)                .then(this.onLoginSuccess.bind(this))                .catch(this.onLoginFail.bind(this));            });    }    onLoginSuccess(){        this.setState({email: '', password: '', error: '', loading: false});    }    onLoginFail(){        this.setState({error: 'NIE udalo sIE utworzyc konta.', loading: false});    }    render(){        return(            <VIEw style={styles.container}>                <VIEw style={styles.imageContainer}>                    <Image                         style={styles.image}                        source={require('../images/loginIcon.png')}                    />                </VIEw>                <VIEw style={styles.formContainer}>                    <Textinput                        style={styles.input}                        placeholder="Email..."                        placeholderTextcolor='rgba(255,255,255,0.9)'                        underlinecolorAndroID='rgba(0,0,0,0)'                        onChangeText={(email) => this.setState({email: email})}                        value={this.state.email}                        autoCorrect={false}                    />                    <Textinput                        style={styles.input}                        placeholder="Hasło..."                        placeholderTextcolor='rgba(255,255,255,0.9)'                        underlinecolorAndroID='rgba(0,0,0,0)'                        autoCorrect={false}                        onChangeText={(password) => this.setState({password: password})}                        value={this.state.password}                        secureTextEntry                    />                    <touchableOpacity style={styles.buttonContainer}>                        <Text style={styles.button}>                            Zaloguj się                        </Text>                    </touchableOpacity>                    <Text style={styles.error}>                        {this.state.error}                    </Text>                </VIEw>            </VIEw>        );    }}

我很困惑如何解决这个问题.提前致谢.

解决方法:

尝试这个:

从App.Js中删除firebase import语句:

import firebase from 'firebase'

在Firebase初始化时创建一个常量:

initializefirebase() {  const firebase = require("firebase");  // Initialize Firebase  var config = {  ...  };  firebase.initializeApp(config);  //inicializando o firestore  const firestore = require("firebase/firestore");  db = firebase.firestore();  db.settings({ timestampsInSnapshots: true });}componentwillMount() {  this.initializefirebase();...}

对我来说,这个解决方案非常有效!

总结

以上是内存溢出为你收集整理的javascript – React native – 对象无效作为React子对象(找到:具有键{$$typeof,type,key,ref,props,_owner,_store}的对象)全部内容,希望文章能够帮你解决javascript – React native – 对象无效作为React子对象(找到:具有键{$$typeof,type,key,ref,props,_owner,_store}的对象)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1103008.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存