React native React Native:await是一个保留字
我试图保存我的用户已登录的事实,然后在他的管理页面上重定向他,但当我使用Wait时,我出现以下错误: wait是一个保留字(101) 另一件事,一旦我的用户注册,我想把他发送到一个新页面,而不是一个“幻灯片页面”,在那里我们可以用右上角的箭头返回。 我该怎么做 这是我的代码:React native React Native:await是一个保留字,react-native,asyncstorage,React Native,Asyncstorage,我试图保存我的用户已登录的事实,然后在他的管理页面上重定向他,但当我使用Wait时,我出现以下错误: wait是一个保留字(101) 另一件事,一旦我的用户注册,我想把他发送到一个新页面,而不是一个“幻灯片页面”,在那里我们可以用右上角的箭头返回。 我该怎么做 这是我的代码: login(){ firebase.auth().signInWithEmailAndPassword(this.state.emailLogin, this.state.passwordLogin).
login(){
firebase.auth().signInWithEmailAndPassword(this.state.emailLogin,
this.state.passwordLogin).then((user) => {
// Send the user to the next step
try {
await AsyncStorage.setItem('@MySuperStore:key', 'I like
to save it.');
} catch (error) {
// Error saving data
}
const { navigate } = this.props.navigation;
navigate('Admin');
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(error);
});
}
提前感谢您的帮助。在函数中使用
wait
时,必须将其标记为async
this.state.passwordLogin).then( aysnc (user) => {
...
})
在函数中使用
wait
时,必须将其标记为async
this.state.passwordLogin).then( aysnc (user) => {
...
})