I found that in my composable is recomposing every time the
hue
,
saturation
, or
value
params change. But if their type to a lambda producing a float,
() -> Float
, there's no recomposing and its skipped. I'm curious why this works and if it's good to do this change.
@Composable
public fun RingColorPicker(
hue: Float,
saturation: Float = 1f,
value: Float = 1f,
onHueChange: (Float) -> Unit,
modifier: Modifier = Modifier,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
ringStrokeWidth: Dp = 16.dp,
thumb: @Composable () -> Unit = {
ColorPickerDefaults.Thumb(Color.hsv(hue, saturation, value), interactionSource)
},
onColorChangeFinished: () -> Unit = {}
)