3

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):

Layout Inspector recomposition counts of ModalBottomSheet Surface

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.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
PadySo
  • 55
  • 5

1 Answers1

1

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.

Abhilash
  • 61
  • 5