Daniel Okanin
08/08/2022, 6:05 PMFrancesc
08/08/2022, 7:03 PMStylianos Gakis
08/08/2022, 7:30 PMDaniel Okanin
08/08/2022, 7:43 PMStylianos Gakis
08/08/2022, 7:51 PMval x by remember { mutableSatateOf(0) }
and you never read that x
inside composition then it won’t trigger a recomposition. It only does so if you’re reading that value somewhere in composition. That’s also how if you only read the value in a “smaller” scope you get the smarter recomposition where only that specific scope gets recomposed as opposed to the scope in which the mutableStateOf
is defined.
Just make sure you don’t do the val (x, setX) = remember { mutableStateOf(0) }
syntax as that one does indeed read the value and therefore triggers recompositions at that level every time the state changes.Daniel Okanin
08/08/2022, 8:19 PMvar counter = remember {0}
Column(modifier = modifier
.fillMaxWidth()
.clickable(
onClick = { onClickEventListener?.onClick(++counter) },
indication = rememberRipple(),
interactionSource = remember { MutableInteractionSource() }
)
)
Francesc
08/08/2022, 8:20 PMDaniel Okanin
08/08/2022, 8:26 PMFrancesc
08/08/2022, 8:28 PM