Javascript 需要一些登录表单的帮助吗

Javascript 需要一些登录表单的帮助吗,javascript,firebase,react-native,firebase-authentication,Javascript,Firebase,React Native,Firebase Authentication,我得到以下错误: 不变冲突:元素类型无效:需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象。您可能忘记了从定义组件的文件中导出组件 有人能帮我找出我的错误在哪里吗 这是我的密码: import React from 'react'; import {View, Button, Text} from 'react-native'; import * as firebase from 'firebase'; import HomeScreen from '../components

我得到以下错误:

不变冲突:元素类型无效:需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象。您可能忘记了从定义组件的文件中导出组件

有人能帮我找出我的错误在哪里吗

这是我的密码:

import React from 'react';
import {View, Button, Text} from 'react-native';
import * as firebase from 'firebase';
import HomeScreen from '../components/HomeScreen';
import {createStackNavigator} from 'react-navigation';
import {FormLabel, FormInput} from 'react-native-elements';

export default class Login extends React.Component {
  constructor(props){
    super(props);
    this.state = {email:'', password:'', error:'', loading: false};
  }

  onLoginPress(){
    this.setState({error:'', loading: true});
    const {email, password} = this.state;
    firebase.auth().signInWithEmailAndPassword(email, password)
    .then(() => {
      this.setState({error:'', loading: false})
      this.props.navigation.navigate('HomeScreen')
    })
    .catch(() =>{
      this.setState({error:'Authentication failed', loading: false});
    })
  }

  onSignUpPress(){
    this.setState({error:'', loading: true});
    const {email, password} = this.state;
    firebase.auth().createUserWithEmailAndPassword(email, password)
    .then(() => {
      this.setState({error:'', loading: false})
      this.props.navigation.navigate('HomeScreen')
    })
    .catch(() =>{
      this.setState({error:'Authentication failed', loading: false});
    })
  }

  renderButtonOrLoading(){
    if(this.state.loading){
      return <Text> Loading </Text>
    }
    return <View>
      <Button
      onPress={this.onLoginPress.bind(this)} 
      title='Login'/> 
       <Button
      onPress={this.onSignUpPress.bind(this)}
      title='Sign Up'/>
    </View>
  }

  render(){
    return(
      <View>
         <Label> Email </Label>
    <Input
    label={"Login"}
    value={this.state.email}
    placeholder='john@gmail.com' 
    onChangeText={email => this.setState({email})}/>
    <Label> Password </Label>
    <Input
    label={"Login"}
    value={this.state.password}
    secureTextEntry
    placeholder='********'
    onChangeText={password => this.setState({password})}/>
    <Text>{this.state.error}</Text>
    {this.renderButtonOrLoading()}
      </View>
    )
  }

}
从“React”导入React;
从“react native”导入{View,Button,Text};
从“firebase”导入*作为firebase;
从“../components/HomeScreen”导入主屏幕;
从“反应导航”导入{createStackNavigator};
从“react native elements”导入{FormLabel,FormInput};
导出默认类登录扩展React.Component{
建造师(道具){
超级(道具);
this.state={电子邮件:“”,密码:“”,错误:“”,加载:false};
}
onLoginPress(){
this.setState({错误:“”,正在加载:true});
const{email,password}=this.state;
firebase.auth().signiWithEmailandPassword(电子邮件,密码)
.然后(()=>{
this.setState({错误:“”,加载:false})
this.props.navigation.navigate('主屏幕')
})
.catch(()=>{
this.setState({错误:'Authentication failed',加载:false});
})
}
onSignUpPress(){
this.setState({错误:“”,正在加载:true});
const{email,password}=this.state;
firebase.auth().createUserWithEmailAndPassword(电子邮件,密码)
.然后(()=>{
this.setState({错误:“”,加载:false})
this.props.navigation.navigate('主屏幕')
})
.catch(()=>{
this.setState({错误:'Authentication failed',加载:false});
})
}
renderButtonOrLoading(){
if(this.state.loading){
回装
}
返回
}
render(){
返回(
电子邮件
this.setState({email}}/>
密码
this.setState({password}}/>
{this.state.error}
{this.renderbuttonorload()}
)
}
}
以下是错误:


我设法让它使用以下代码:

import React from 'react';
import {View} from 'react-native';
import {Input} from 'react-native-elements';

export default class FormExample extends React.Component {
  render(){
    return(
      <View>
        <Input
        label={"Login"}/>
      </View>
    )
  }
}
从“React”导入React;
从“react native”导入{View};
从“react native elements”导入{Input};
导出默认类FormExample扩展React.Component{
render(){
返回(
)
}
}

请在您的文件中显示导入内容,而且以这种方式直接访问此状态是不好的做法。建议您改用
setState()
。好的,您现在可以看到我的导入,firebase的部分除外。就是这样。
this.state({error:'',loading:false})
是错误的。将所有
this.state()
更改为
this.setState()
,也看到了,所以我只需要在输入中添加一个标签?是的,将其作为输入的属性抱歉:D,但这是新输入还是我必须将其放入我的输入中,因为我有一个用于电子邮件,一个用于密码。或者两者都用?只需编辑并将“更新”放在新代码的末尾,您就可以检查它了