Dhya Pacifica
09/20/2023, 3:11 AMval radioOptions = listOf("Calls", "Missed", "Friends")
val (selectedOption, onOptionSelected) = remember { mutableStateOf(radioOptions[0]) }
Which is from the Compose RadioButton example. Am familiar with hoisting when there is one parameter, but in this case there is the extra parameter onOptionSelected which is throwing me off.
Currently I have the child composable accepting the two parameters like:
@Composable
fun QuestionRadioButtons(
selectedOption: String,
onOptionSelected: (String) -> (Unit)
) { ... }
Kirill Grouchnikov
09/20/2023, 3:40 AMDhya Pacifica
09/20/2023, 3:42 AMKirill Grouchnikov
09/20/2023, 3:44 AMx
as the current state to “display” in the UI, and an onXSomething
as the lambda to call upwards when the user interacts with that data display, and that interaction should lead to a state changeDhya Pacifica
09/20/2023, 3:47 AMKirill Grouchnikov
09/20/2023, 3:48 AMonOptionSelected
is a lambda generated for you with no validation, custom acceptance or rejection, persistence or any other part of it you would have in the real app.mutableStateOf
see the code in https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]c/commonMain/kotlin/androidx/compose/runtime/SnapshotState.kt