Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

You should not use collectAsState for navigation #38

Open
bigfarid opened this issue Nov 5, 2021 · 0 comments
Open

You should not use collectAsState for navigation #38

bigfarid opened this issue Nov 5, 2021 · 0 comments

Comments

@bigfarid
Copy link

bigfarid commented Nov 5, 2021

navigationManager.commands.collectAsState().value.also { command ->
if (command.destination.isNotEmpty()) {
navController.navigate(command.destination)
}
}

Can cause nullpointer exceptions on recomposition because the navgraph is not initialized yet. It shoudl be something like:
LaunchedEffect(navigationManager.commands){
navigationManager.commands.collect{ command ->
if (command.destination.isNotEmpty()) {
navController.navigate(command.destination)
}
}
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant