Daniele B
05/10/2021, 3:09 PMNavHostController.navigate()
as in:
val navController = rememberNavController()
navController.navigate("detail")
It seems no recomposition is triggered.
What is the basis on which Compose is able to update the screen without a recomposition?
And how can we achieve the same in a Compose non-Android app?Ian Lake
05/10/2021, 3:34 PMIan Lake
05/10/2021, 3:36 PMcurrentBackStackEntryAsState()
- that state is updated when you navigate and that is what causes your UI to recompose (only on the parts of the hierarchy that depend on said state)Ian Lake
05/10/2021, 3:36 PMNavHost
itself, which certainly recomposes when you change destinationsDaniele B
05/10/2021, 3:42 PMyou should never be calling imperative code, like navigate, as part of compositionyes, of course, that code was a simplification. I am always calling
navigate
from onClick functionsDaniele B
05/10/2021, 3:43 PMIan Lake
05/10/2021, 3:50 PMcurrentBackStackEntryAsState()
- see the example in the docs: https://developer.android.com/jetpack/compose/navigation#bottom-navLucien Guimaraes
05/11/2021, 10:55 AMIan Lake
05/11/2021, 1:23 PMLucien Guimaraes
05/11/2021, 1:44 PMLucien Guimaraes
05/11/2021, 1:45 PM