【问题标题】:TypeError: undefined is not an object 'createElement' of undefined - React NativeTypeError:未定义不是未定义的对象'createElement' - React Native
【发布时间】:2018-12-21 08:13:11
【问题描述】:

我有一个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”

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

我希望得到这样的东西

如何进一步调试?

【问题讨论】:

    标签: javascript reactjs react-native


    【解决方案1】:

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

    import React, { Component } from 'react';
    

    【讨论】:

      猜你喜欢
      • 2017-03-28
      • 1970-01-01
      • 2019-04-05
      • 2021-11-09
      • 1970-01-01
      • 2021-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多