audriusk
01/15/2021, 5:55 PM@Composable
fun ComposableA() {
val stateA by savedInstanceState { "id" }
ComposableB(stateA) // <-- How to drop all subtree state on stateA change?
}
@Composable
fun ComposableB(state: String) {
val stateB by savedInstanceState { "stateB" }
// deep nested structure with more states
}
I want ComposebleB
to be composed with fresh child states when stateA
changes. What would be right way to achieve such behavior?Casey Brooks
01/15/2021, 6:07 PMstateA
as the “key” for the child states’ remember { ]
calls
See “Remember with keys” header of the following article (because Medium is awful and I can’t link directly to that section) https://medium.com/mobile-app-development-publication/android-jetpack-compose-remember-made-easy-8bd86a48536caudriusk
01/15/2021, 6:16 PMkey
for each property in sub-tree? ComposableB
is complex nested component. Is there an easier way to recompose it with fresh states?