admin管理员组文章数量:1357672
I have a dynamic route like /pattern/[id]
which these items can navigate to related items so only the id
changes. I want the Back button to go back, so pattern/3 > pattern/2. However, the back button dismisses the entire stack and leaves the pattern
entirely.
Yes, I do router.push
not replace:
router.push({
pathname: '(auth)/pattern/[id]',
params: { id: label, },
});
I have seen a suggestion to install react-native-screens, but I would like to avoid another dependency. I also tried a suggestion to add a custom key
to the Stack
like:
<Stack
screenOptions={({ route }) => {
const params = route.params as { id?: string } | undefined;
return {
headerStyle: {
backgroundColor: 'transparent',
},
key: `pattern-${params?.id}`,
headerShown: true,
headerTransparent: true,
headerBackVisible: false,
headerShadowVisible: false,
title: '',
headerLeft: () => <ChevronBack direction="left" />,
// headerRight: () => {
// return <FullScreenModalBackButton />;
// },
};
}}
>
Any ideas what else can be done to allow router.back to go back to previous param in the stack?
本文标签: react nativerouterback with dynamic route dismisses entire stackStack Overflow
版权声明:本文标题:react native - router.back with dynamic route dismisses entire stack - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744075446a2586661.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论