I'm working with compose now for several weeks and some things are still quite challenging or weird I think.
My newest feature requires a BottomSheet, a ModalBottomSheet to be precise.
When inspecting via the Layout Inspector it shows me, that the ModalBottomSheet sheetcontent, that is a surface, produces enormous recomposition counts. (I'm talking about hundres per second):

I even tried emptying the whole ModalBottomSheet so it's only an empty shell like this:
val sheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
confirmStateChange = { it != ModalBottomSheetValue.HalfExpanded },
skipHalfExpanded = true,
)
ModalBottomSheetLayout(
sheetState = sheetState,
sheetShape = CustomTheme.shapes.bottomSheetRadius,
sheetContent = {
Column(modifier = Modifier.padding(bottom = 10.sdp)) {
}
}
) {
}
Someone experienced the same? I can not find anyone complaining about this.. But this can not be okay I think.
The recomposition count comes from the animation of modal bottom sheet. You can see these exact recomposition count in any animation api.
It is not really a problem unless you put the entire UI component in sheetContent directly. You have to create a separate composable with only stable parameters to avoid any kind of real problem. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With