Let's say I have such code ```@Composable fun Comp...
# compose
a
Let's say I have such code
Copy code
@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?
c
Rather than imperatively clearing the state, you might use a property of
stateA
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-8bd86a48536c
a
In that case I would have to set
key
for each property in sub-tree?
ComposableB
is complex nested component. Is there an easier way to recompose it with fresh states?