I am trying to implement react navigation v5
's deep linking system to my react native
app. So far its working but I am started get confused. So my aim is make initial screen
to get params while navigating to specified screen. I can explain it better with code:
const config = {
screens: {
HomeStack: {
screens: {
Home: {
screens: {
SearchStack: {
initialRouteName: 'Search',
screens: {
PostDetailStack: {
initialRouteName: 'PostDetail',
screens: {
PostDetail: 'post-detail/:postId',
CommentDetail: 'post-detail/:postId/:comment/:commentId'
}
}
}
}
}
}
}
},
AuthStack: {
screens: {
ChangePassword: 'reset/:uid/:token'
}
}
}
}
So while navigating to CommentDetail
screen I also want to pass params to PostDetail
screen. In react navigation
docs it says I need to use getStateFromPath(path, config)
to copy params but I don't know how to use that. I tried to convert this route to state but I got confused and I also don't get when we use index
in navigation state and when we don't.
So how can I convert this to proper navigation state that initial screen
also gets the params?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…