Ios firebase身份验证成功后,React本机应用程序未导航
我正在使用expo构建我的第一个react本机应用程序,到目前为止非常棒,我只对一个问题感到失望: 成功登录后,我的应用程序未重定向到“配置文件”。以下是我如何使用firebase处理登录/注册:Ios firebase身份验证成功后,React本机应用程序未导航,ios,firebase,react-native,firebase-authentication,Ios,Firebase,React Native,Firebase Authentication,我正在使用expo构建我的第一个react本机应用程序,到目前为止非常棒,我只对一个问题感到失望: 成功登录后,我的应用程序未重定向到“配置文件”。以下是我如何使用firebase处理登录/注册: class Login extends React.Component { state = { email: '', password: '' } handleLogin = () => { const { email, password } = this.state
class Login extends React.Component {
state = {
email: '',
password: ''
}
handleLogin = () => {
const { email, password } = this.state
Firebase.auth()
.signInWithEmailAndPassword(email, password)
.then(() => this.props.navigation.navigate('Profile'))
.catch(error => console.log(error))
}
render() {
return (
<View style={styles.container}>
<Text style={styles.headerText}>traderank</Text>
<TextInput
style={styles.inputBox}
value={this.state.email}
onChangeText={email => this.setState({ email })}
placeholder='email'
autoCapitalize='none'
/>
<TextInput
style={styles.inputBox}
value={this.state.password}
onChangeText={password => this.setState({ password })}
placeholder='password'
secureTextEntry={true}
/>
<TouchableOpacity
style={styles.button}
onPress={this.handleLogin}>
<Text style={styles.buttonText}>login</Text>
</TouchableOpacity>
<Button
title="no account? sign up"
onPress={() => this.props.navigation.navigate('Signup')}/>
</View>
)
}
}
1) 我知道我的导航器没有问题,因为我可以通过单击按钮在登录/注册之间切换
2) 我知道firebase没有问题,因为我可以创建一个新用户并在firebase控制台中查看该用户
3) 单击“登录”时出现此错误:
错误:无法创建存储目录。错误域=nscocaerorDomain代码=4“文件”RCTAsyncLocalStorage“不存在。”
UserInfo={NSFilePath=/Users/me/Library/Developer/CoreSimulator/Devices/264989F0-2165-4E91-8EA3-48316590DE5A/data/Containers/data/Application/A49D7AF5-C660-4292-9576-A986C3F97C38/Documents/experiencedata/%40匿名%项目编号/RCTAsyncLocalStorage,NSUnderlyingError=0x60000778180
{Error Domain=NSPOSIXErrorDomain Code=2“没有这样的文件或目录”}
当我单击“注册”时,它也应该重定向,但当我创建一个新用户时,我会在我的终端中看到该用户被登录[当我单击“注册”时正在创建用户,我会在firebase控制台中看到用户]:
未能创建存储目录。错误域=nscocaerorrordomain Code=4“文件”RCTAsyncLocalStorage“不存在。”
在这两种情况下,RCTAsyncLocalStorage似乎都存在问题。通常我可以在谷歌上搜索错误并找出答案,但在这方面还没有发现太多。我正在使用react native expo~39.0.2,在iPhone11(13.7)上运行它
提前感谢我认为发生此错误是因为您的模拟器出现问题, 尝试更改它或使用其他手机并在其上运行应用程序 有个问题和你的问题有关,
您可以从查看登录屏幕的测试结果吗?当然,我一到家就会更新@WenW更新为完整登录我的登录屏幕看起来不错。您是否有条件地在导航器中呈现配置文件页面?类似于这里正在做的事情@我们还没有条件渲染。我应该那样做吗?太好了!我把模拟器换成了另一种设备,它成功了——谢谢!
handleSignUp = () => {
const { email, password } = this.state
Firebase.auth()
.createUserWithEmailAndPassword(email, password)
.then(() => this.props.navigation.navigate('Profile'))
.catch(error => console.log(error))
}