I copy a `mutableStateListOf` example from docs without any changes, but it doesn't seem to work. AFAIU it should add new names, but the list on the screen stays empty. If I change it to
var names = remember { mutableStateListOf<String>() }
it starts to work. Is it a mistake in docs or am I doing/expecting something wrong?
Denis
02/07/2021, 6:56 AM
Code from the link:
Copy code
@Composable
fun Names() {
var name by remember { mutableStateOf("user") }
val names = mutableStateListOf<String>()
Column {
Row {
BasicTextField(
value = name,
onValueChange = { name = it }
)
Button(onClick = { names.add(name) }) {
Text("Add")
}
}
Text("Added names:")
Column {
for (addedName in names) {
Text(addedName)
}
}
}
}