admin管理员组文章数量:1332976
After updating to "@react-navigation/native": "^7.0.3"
, using linkTo
from useLinkTo()
isn't working as it used to in ReactNative.
My linking config is somewhat complex:
const config = {
screens: { // Root navigator: Menu Nav
StackNav: {
screens: {
TabContainer: '/places',
TabsNav: {
screens: {
Screen1: `/summary`,
Screen2: '/stats',
},
},
Screen3: '/account'
}
},
Screen4: '/chat'
}
}
...and using useLinkTo()
to link to /stats
isn't working anymore. It used to work in 6.x. I'm using it from within my own app to navigate when I might not have a
It works fine so far for StackNav
and ChatScreen
, but not for anything in TabsNav
.
What's happening:
- RN seems to be able to find the route, if I comment out the
/stats
line in the config, it crashes when I try to nav saying:Error: Failed to parse the href to a navigation state.
- RN just isn't navigating. It silently does nothing.
- linkTo to
/account
works just fine
I know that with 7.x, navigating to nested navigators isn't supported and in the docs (.x/#changes-to-the-navigate-action) they explicitly mention that and how to use navigation.navigate(...)
with some new props in order to do so.
But what about linkTo(...)
? Was it also affected?
After updating to "@react-navigation/native": "^7.0.3"
, using linkTo
from useLinkTo()
isn't working as it used to in ReactNative.
My linking config is somewhat complex:
const config = {
screens: { // Root navigator: Menu Nav
StackNav: {
screens: {
TabContainer: '/places',
TabsNav: {
screens: {
Screen1: `/summary`,
Screen2: '/stats',
},
},
Screen3: '/account'
}
},
Screen4: '/chat'
}
}
...and using useLinkTo()
to link to /stats
isn't working anymore. It used to work in 6.x. I'm using it from within my own app to navigate when I might not have a
It works fine so far for StackNav
and ChatScreen
, but not for anything in TabsNav
.
What's happening:
- RN seems to be able to find the route, if I comment out the
/stats
line in the config, it crashes when I try to nav saying:Error: Failed to parse the href to a navigation state.
- RN just isn't navigating. It silently does nothing.
- linkTo to
/account
works just fine
I know that with 7.x, navigating to nested navigators isn't supported and in the docs (https://reactnavigation./docs/upgrading-from-6.x/#changes-to-the-navigate-action) they explicitly mention that and how to use navigation.navigate(...)
with some new props in order to do so.
But what about linkTo(...)
? Was it also affected?
1 Answer
Reset to default 0Turns out I had to include the path to the navigator as well in the path.
Updated config to:
const config = {
screens: { // Root navigator: Menu Nav
StackNav: {
screens: {
TabsNav: {
path: '/places',
screens: {
Screen1: `/summary`,
Screen2: '/stats',
},
},
Screen3: '/account'
}
},
Screen4: '/chat'
}
}
...and updated the linkTo
from /stats
to /places/stats
.
Snack: https://snack.expo.dev/@acrabb713/143a82
本文标签: linkTo no longer working in React Navigation 7Stack Overflow
版权声明:本文标题:linkTo no longer working in React Navigation 7 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742344523a2457257.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论