gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 12:15:08 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com