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?
Blundell
02/28/2021, 10:04 PM
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
Blundell
02/28/2021, 10:15 PM
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
Ian Lake
02/28/2021, 10:27 PM
Yeah, your start destination, just like every other destination, is drawn by the NavHost; you don't need to draw it separately
👍 1
b
Blundell
02/28/2021, 10:50 PM
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
Ian Lake
03/01/2021, 12:29 AM
The docs do explicitly say
Copy code
As you navigate between composables, the content of the NavHost is automatically recomposed.
Ian Lake
03/01/2021, 1:02 AM
Do you think some other wording would be more clear?
b
Blundell
03/07/2021, 7:44 PM
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