如何打开新屏幕?
比如: navigation.navigate('Home"(
async function handleLoginWithPhonePressed() {
try {
------------------------
}
catch (err) {
//Alert.alert(`Failed to login with phone ${err.message}`)
{() => navigation.navigate('Home")}
}
}
我真的不明白你的问题,因为你已经回答了自己。
将 Alert.alert 替换为路由器的代码。
try{
.....
}
catch{
//open the new screen or next page
//navigation.navigate("xyz")
}
async function handleLoginWithPhonePressed() {
try {
const token = await AccountKit.loginWithPhone()
if (!token) {
Alert.alert('User cancelled the login with phone action!')
return
}
setAuthToken(token)
getCurrentUser()
}
catch (err) {
Alert.alert(Failed to login with phone ${err.message})
}
}
这是正确的答案。
this.props.navigation.navigate('Home"(
async function handleLoginWithPhonePressed() {
try {
------------------------
}
catch (err) {
//Alert.alert(`Failed to login with phone ${err.message}`)
//{() => navigation.navigate('Home")}
this.props.navigation.navigate('Home");
}
}