mohamed rejeb
03/25/2023, 4:38 PMmohamed rejeb
03/25/2023, 4:41 PMplaceholderState but if I keep it inside the big state the components in TabRow get recomposed even if there's no change to the states related to the TabRow
@Composable
fun App(appComponent: AppComponent) {
val state = appComponent.state.collectAsState()
val placeholderState by appComponent.placeholderState.collectAsState()
Column(
modifier = Modifier.fillMaxSize()
) {
TabRow(
state = { state.value },
onUndo = appComponent::undo,
onRedo = appComponent::redo
)
MyCanvas(
state = { state.value },
placeholderState = { placeholderState },
onCanvasEvent = { appComponent.onCanvasEvent(it) },
modifier = Modifier
.fillMaxWidth()
.weight(1f)
.padding(20.dp)
.border(1.dp, Color.Red)
.clipToBounds()
)
}
}s3rius
03/25/2023, 9:08 PMAppComponent is unstable and I think function references to unstable objects tend to be unstable too, so when anything in state changes, TabRow and MyCanvas can't be skipped because the compiler can't figure out that nothing happened.