chanjungskim
03/03/2023, 9:51 AMchanjungskim
03/03/2023, 9:53 AM@Composable
fun QuestionField(
title: String,
answerType: Question.SurveyType,
choiceList: List<BChoice>,
onAnswer: (HashMap<String, String>) -> Unit,
modifier: Modifier = Modifier
) {
Log.d("aos", "choiceList: $choiceList")
var choices by remember { mutableStateOf(choiceList) }
Log.d("aos", "choices: $choices")
...
}
If I don't use
var choices by remember { mutableStateOf(choiceList) }
this part, then, it prints. but if I use this, even the first debug log isn't printed. Why is that?
And here's the button part in the function to reassign the choices data to make it recomposable.
onNotifyButtonState = { index, isChecked ->
choices = choices.mapIndexed { idx, bChoice ->
if (idx != index) {
choice.copy(isChecked = false)
}
choice
}
Log.d("aos", "list: $choiceList")
},
modifier = Modifier
.width(166.dp)
.height(80.dp)
.clickable {
onAnswer.invoke(hashMapOf(ANSWER_REF to "${choice.aRef}"))
}
chanjungskim
03/03/2023, 9:57 AM