javascript - 类型错误 : undefined is not an object 'createElement' of undefined - React Native

标签 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

类型错误:无法读取未定义的属性“createElement”

This error is located at: in LoginForm (at App.js:26) in RCTView (at View.js:43) in App (at renderApplication.js:32) in RCTView (at View.js:43) in RCTView (at View.js:43) in AppContainer (at renderApplication.js:31)

enter image description here

我希望得到这样的东西

enter image description here

如何进一步调试这个问题?

最佳答案

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

import React, { Component } from 'react';

关于javascript - 类型错误 : undefined is not an object 'createElement' of undefined - React Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51316781/

相关文章:

javascript - 无法将参数从ajax传递到php

javascript - 尝试循环出nodeJS中的旧日志仍然会写入循环出的文件

javascript - React + Typescript 高阶函数 "not assignable to type"错误

javascript - React-Native:警告:无法对未安装的组件执行 React 状态更新

javascript - 中间固定位置div

javascript - 在子组件 Prop 上使用父 Prop

javascript - "Uncaught TypeError: history.push is not a function"发生错误

javascript - 为什么父级 onClick 在子级 onChange 之前触发

react-native-maps 自定义 map 样式

javascript - (帮助)React Native JSON 文件太大。 Bundler 堆内存不足