I’m passing in a NavController to a Column inside ...
# compose
b
I’m passing in a NavController to a Column inside a LazyColumn and using the Columns onClick to navigate. (i.e. navigation from a list item.) I’ve logged & debugged inside the receiving composable and the navigation works, but the screen does not update. The old screen stays visible and all the list items still look clickable. Can’t see anything in the logs. How do I go out debugging this?
maybe it’s being rendered underneath the current view or something like that? Not sure how the current view is cleared when I navigate tbh
Problem seemed to be that I need to return the NavHost to setContent method. I was doing the initial rendering as well as setting the NavHost. So I believe the navigation was happening underneath a static drawing (i.e. duplicate) of my main screen 😄
i
Yeah, your start destination, just like every other destination, is drawn by the NavHost; you don't need to draw it separately
👍 1
b
Took me a little while to realise that! Since I started with a working screen then added the NavHost, (the page here https://developer.android.com/jetpack/compose/navigation doesn’t explicitly show where the NavHost goes / what it replaces)
i
The docs do explicitly say
Copy code
As you navigate between composables, the content of the NavHost is automatically recomposed.
Do you think some other wording would be more clear?
b
I’m only just picking up Compose so that doesn’t really explain it for me. But also because I randomly started learning from here first most other ppl maybe will get it! I would have understood it faster, if the code examples on the page showed how the
NavHost
interacts with
setContent
i.e. how you start with NavHost