簡體   English   中英

TypeError:未定義不是未定義的對象'createElement'-React Native

[英]TypeError: undefined is not an object 'createElement' of undefined - React Native

我有一個LoginForm.js組件

import { React, Component } from 'react';
import { Button, Card, CardSection } from './common';

class LoginForm extends Component {
    render() {
        return (
            <Card>
                <CardSection />

                <CardSection />

                <CardSection>
                    <Button>
                        Login
                    </Button>
                </CardSection>


            </Card>
        );
    }

}

export default LoginForm;

我試圖像這樣將其集成到我的App.js中

import React, { Component } from 'react';
import { View } from 'react-native';
import firebase from 'firebase';

import { Header } from './components/common';
import LoginForm from './components/LoginForm';


class App extends Component {


    componentWillMount() {
        firebase.initializeApp({
            apiKey: '*********',
            authDomain: 'rn-auth-a3fb5.firebaseapp.com',
            databaseURL: 'https://rn-auth-a3fb5.firebaseio.com',
            projectId: 'rn-auth-a3fb5',
            storageBucket: 'rn-auth-a3fb5.appspot.com',
            messagingSenderId: '34567890'
        });
    }
    render() {
        return (
            <View>
                <Header headerText='Authentication' />
                <LoginForm />

            </View>

        );
    }
}
export default App;

我一直出錯

在此處輸入圖片說明

TypeError:無法讀取未定義的屬性“ createElement”

此錯誤的位置是:RCTView(位於View.js:43)的RCTView(位於ViewApplication.js:32)的RCTView(位於View.js:43)的LoginForm(位於App.js:43) AppContainer中的View.js:43)(位於renderApplication.js:31)

在此處輸入圖片說明

我希望得到這樣的東西

在此處輸入圖片說明

人們將如何進一步調試呢?

您在LoginForm.js React導入不正確。 React應該是默認導入。

import React, { Component } from 'react';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM