TypeError:未定义不是未定义的对象'createElement'-React Native

时间:2018-07-13 02:13:27

标签: javascript reactjs 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;

我一直遇到错误

enter image description here

TypeError:无法读取未定义的属性'createElement'

  

此错误位于:       在LoginForm中(在App.js:26)       在RCTView中(在View.js:43)       在App中(在renderApplication.js:32)       在RCTView中(在View.js:43)       在RCTView中(在View.js:43)       在AppContainer中(在renderApplication.js:31)

enter image description here

我希望得到这样的东西

enter image description here

如何进一步调试呢?

1 个答案:

答案 0 :(得分:5)

您在LoginForm.js中的React导入不正确。 React应该是默认导入。

import React, { Component } from 'react';