https://kotlinlang.org logo
#compose
Title
# compose
j

Jorge Domínguez

05/25/2022, 4:44 PM
Is the usage of the
when
statement here bad for performance considering recompositions?
Copy code
@Composable
private fun ExampleDropdownMenu(
    someEnum: SomeEnum,
    expanded: Boolean,
    items: List<String>,
    onDismissRequest: () -> Unit,
) {
    DropdownMenu(
        expanded = expanded,
        onDismissRequest = onDismissRequest
    ) {
        items.forEach() { item ->
            DropdownMenuItem(onClick = { ... }) {
                Text(
                    text = when (someEnum) {
                        SomeEnum.A -> item.formatA()
                        SomeEnum.B -> item.formatB()
                    }
                )
            }
        }
    }
}
z

Zach Klippenstein (he/him) [MOD]

05/25/2022, 4:55 PM
no
😄 1
s

Satyam G

05/26/2022, 8:10 AM
ABSOLUTELY NO, This is the standard followed for conditional parameters in case of Jetpack Compose
3 Views