慕蓋茨4494581
2023-06-09 17:41:34
AuthStack所以我有一個像這樣命名的堆棧const AuthStack = ({ resetPassword, updateEmail }: any) => ( <Stack.Navigator screenOptions={{ cardStyle: { backgroundColor: '#F2F1F7' }, headerShown: true, headerTitle: '', }} > {resetPassword ? ( <Stack.Screen name="Reset Password">{(props: any) => <ResetPassword />}</Stack.Screen> ) : updateEmail ? ( <Stack.Screen name="Update Email">{(props: any) => <UpdateEmail />}</Stack.Screen> ) : ( <Stack.Screen name="Home">{(props: any) => <Home />}</Stack.Screen> )} </Stack.Navigator>)很高興知道這是否是正確的方法。但基本上在我的帳戶頁面上,我有重置密碼和更新電子郵件的鏈接。我將這兩個都放在 AuthStack 中,因為我不確定這是否是最好的地方。無論如何這種工作,但是如果我點擊“更新電子郵件”并導(dǎo)航到那里,如果我然后決定實際上我想去另一個頁面并導(dǎo)航離開,如果我然后通過點擊“主頁”導(dǎo)航回來,它仍然帶我到更新電子郵件頁面。盡管此時我真的很想顯示主屏幕。另外,如果我在它處于活動狀態(tài)時單擊主頁,它也不會帶我到那里。這意味著我再也看不到我的主頁了。所以我想知道是否有某種類型的偵聽器,當(dāng)我離開此頁面時,它會始終默認(rèn)顯示主頁?有任何想法嗎?而且我不想顯示重置密碼/更新電子郵件,因為它們有自己的選項卡,因此將它們隱藏在主頁下。有更好的方法嗎?
1 回答

縹緲止盈
TA貢獻(xiàn)2041條經(jīng)驗 獲得超4個贊
我真的不知道你為什么有條件地渲染屏幕,我認(rèn)為你使用名稱的方式很糟糕。您應(yīng)該像 navigation.navigate('ForgotPassowrd') (屏幕名稱)一樣導(dǎo)航。它一直顯示您更新電子郵件,因為主頁不存在。
export const AuthNavigator = () => {
return (
<Stack.Navigator headerMode='none'>
<Stack.Screen name='Home' component={SignupContainer}></Stack.Screen>
<Stack.Screen name='ForgotPassword' component={ForgotPasswordContainer}></Stack.Screen>
<Stack.Screen name='Update Email' component={UpdateEmailContainer}></Stack.Screen>
</Stack.Navigator>
);
};
添加回答
舉報
0/150
提交
取消