React native 可能的未处理承诺拒绝(id:0):引用错误:Can';找不到变量TextInputEmail

React native 可能的未处理承诺拒绝(id:0):引用错误:Can';找不到变量TextInputEmail,react-native,react-native-android,react-native-ios,React Native,React Native Android,React Native Ios,import React,{Component}来自'React'; 导入{视图、文本、图像、图像背景、, TextInput、TouchableOpacity、异步存储、, ActivityIndicator、StatusBar、StyleSheet}来自“react native”; 从“反应导航堆栈”导入{createStackNavigator}; 从“反应导航”导入{createAppContainer,createSwitchNavigator}; 从“../App”导入AppCon

import React,{Component}来自'React';
导入{视图、文本、图像、图像背景、,
TextInput、TouchableOpacity、异步存储、,
ActivityIndicator、StatusBar、StyleSheet}来自“react native”;
从“反应导航堆栈”导入{createStackNavigator};
从“反应导航”导入{createAppContainer,createSwitchNavigator};
从“../App”导入AppContainer
从“../Screens/forget”导入忘记;
类Home扩展组件{
建造师(道具){
超级(道具);
此.state={
TextInputEmail:“”,
TextInputPassword:“”,
};
}
CheckTextInput=async()=>
{
如果(this.state.TextInputEmail!='')
{
如果(this.state.TextInputPassword!='')
{
//如果(userInfo.TextInputEmail===this.state.TextInputEmail&&
//userInfo.TextInputPassword==此.state.TextInputPassword)
取('http://104.197.28.169:3000/auth/login?', {
方法:“POST”,
正文:JSON.stringify({
“电子邮件”:TextInputEmail,
“密码”:TextInputPassword
}),
})
.then((response)=>response.json())
.然后(()=>{
this.props.navigation.navigate('drawernavi'))
log('response object:',responseJson)
})
.catch((错误)=>{
控制台错误(error);
投掷误差;
});
//等待AsyncStorage.setItem('isLoggedIn','1');
//this.props.navigation.navigate('drawernavi'))
//this.userLogin()
//警惕('腿缩进')
//此参数为.userLogin();
}
其他的
警报(“请输入密码”);
}否则
警报(“请输入电子邮件和密码”);
}
render(){
返回(
this.setState({TextInputEmail})}
值={this.state.TextInputEmail}
underlineColorAndroid=“透明”>
this.setState({TextInputPassword})}
值={this.state.TextInputPassword}
underlineColorAndroid=“透明”>
登录
this.props.navigation.navigate('forgotstack')}>
忘记密码了?
);
}
}
我正在创建登录的功能。我在处理它时遇到了这个错误。我是新手。当我尝试登录时,黄色警告开始出现 我通过node.js api获取数据。因此,api和react中的输入字段名称必须相同,也可以不同,或者有其他方法,如果错误,请建议更正我的代码。问题是
if(userInfo.TextInputEmail==this.state.TextInputEmail)
在此条件下,未定义
userInfo
,因此未定义userInfo.TextInputEmail

请检查一下

     body: JSON.stringify({
                  "email": TextInputEmail,
                  "password": TextInputPassword
                }),
//Change it to
 body: JSON.stringify({
                  "email": this.state.TextInputEmail,
                  "password": this.state.TextInputPassword
                }),
     body: JSON.stringify({
                  "email": TextInputEmail,
                  "password": TextInputPassword
                }),
//Change it to
 body: JSON.stringify({
                  "email": this.state.TextInputEmail,
                  "password": this.state.TextInputPassword
                }),