https://kotlinlang.org logo
#decompose
Title
# decompose
s

Shivam Kanodia

09/27/2023, 11:10 AM
Hi , When i am popping of a child component why does my component that opens recomposes? like A->B->C, all of these A,B,C are root components . when i pop off component "C", UI of component "B" recomposes, i have to avoid this, how should i do this? @Arkadii Ivanov . Because this leads to loss of local state that is in ui.
a

Arkadii Ivanov

09/27/2023, 11:31 AM
In general, a Composable function can recompose at any time. Jetpack Compose tries its best to reduce the amount of compositions as much as possible. In this particular case, when you push another screen, the previous screen leaves the composition. And then when you pop the screen, the previous screen enters the composition (the Composable function is called). It may recompose multiple times due to animations running, but this shouldn't lead to any issues at all.
All
remember
-ed state will be lost though. This works the same with all navigation libraries
s

Shivam Kanodia

09/27/2023, 11:40 AM
Got it, thanks! 🙂
2 Views