https://kotlinlang.org logo
#compose
Title
# compose
j

jaqxues

11/03/2020, 3:27 PM
Hello, question about navigation-compose I want to add a
composable
destination to a NavHost at runtime. How do I do so without reloading the current Composable that is seen on the screen? By having a mutable state that is read from
NavHost
, the entire screen is refreshed (and animations look weird, state is reset etc)
i

Ian Lake

11/03/2020, 3:57 PM
This isn't how Navigation works. Your graph must have every possible destination in it when you create it. Think of it as a map of all possible destinations - that doesn't mean you have to use all of the destinations when your app runs though
j

jaqxues

11/03/2020, 3:58 PM
Hm alright
i

Ian Lake

11/03/2020, 4:02 PM
Note that there's a semi-related issue with the NavHost losing state under certain types of recomposition, being tracked in https://issuetracker.google.com/172185423
2 Views