每次插入新邮件和密码后,我都会通过expo通过应用程序注册到应用程序,每次都会显示此屏幕。this is the screen error
即使我关闭了博览会后再次打开,它也会显示带有消息的相同红色屏幕。但是,如果我关闭该项目(通过摇动刷新它)并再次输入整个项目,那么现在该用户已经存在并且可以完美运行……(仍然需要修复)。
这是** Register.js页面代码:**
import React, { Component } from "react";
import { View, Button, StyleSheet, TextInput, Alert, AsyncStorage } from "react-native";
const URL = 'http://185.60.170.14/plesk-site-preview/ruppinmobile.ac.il/site17/WebService.asmx';
export default class Register extends Component {
state = {
email: "",
password: "",
repassword: ""
};
Register = () => {
if(this.state.password != this.state.repassword){
Alert.alert(
"Error",
'Password does not match',
[{ text: "OK", onPress: () => null }],
{ cancelable: false }
);
this.setState({password: '', repassword: ''});
return;
}
let data = {
email: this.state.email,
password: this.state.password
};
fetch(URL + "/Register", {
// בקשה לשרת למתודה Register
body: JSON.stringify(data), // שליחת פרמטרים
method: "POST",
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(res => {
return res.json();
})
.then(userData => {
console.log(userData.d);
if (userData.d == "Error: This email is already in use") {
Alert.alert(
"Error",
userData.d,
[{ text: "OK", onPress: () => null }],
{ cancelable: false }
);
} else {
AsyncStorage.setItem("@KnowingFriends:user", userData.d);
this.props.navigation.navigate("MainApp");
}
})
.catch(err => {
console.error(err);
});
};
render() {
return (
<View style={styles.container}>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ email: text })}
value={this.state.email}
placeholder="Email"
/>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ password: text })}
value={this.state.password}
secureTextEntry={true}
placeholder="Password"
/>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ repassword: text })}
value={this.state.repassword}
secureTextEntry={true}
placeholder="Repeat Password"
/>
<Button onPress={this.Register} title="Submit" color="#841584" />
<Button
onPress={() => {
this.props.navigation.navigate("Login");
}}
title="Go back"
color="#841584"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
input: {
height: 40,
width: 300,
borderColor: "gray",
borderWidth: 1
}
});
如何解决此问题?
我也是同样的问题,但我已经解决了
state = {
text: '',
image: null,
};
已更改
state = {
text: '',
image: '',
};