Crash when specifying arguments in a group navigation initialRoute
Lavmee opened this issue · comments
If we specify arguments in the initialRoute in a group, we get the error "Initial route /nested/1 not found".
Sample:
@Composable
fun AppNavigation() {
val navigator = rememberNavigator()
NavHost(
initialRoute = "/group",
navigator = navigator,
modifier = Modifier.fillMaxSize()
) {
group(
route = "/group",
initialRoute = "/nested/1",
) {
scene(
route = "/nested/{id}"
) {
}
}
}
}
While working on a fix, I was wondering: should this be a bug?
Since currently group support nesting, so we can easily have something like:
group(route = "/group", initialRoute = "/nested/1") {
group(route = "/nested/{id}", initialRoute = "/innternested/2") {
scene(
route = "/innternested/{id}"
) {
}
// ...
}
}
And this might lead to misunderstanding and confusion: which id I'm getting? and how to get group's id?
So I would like to keep the group as simple as possible, remove the support of pattern matching for both the route
and initialRoute
parameter, what do you think?
I think this is a good idea