d

    Denis

    1 year ago
    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?
    Code from the link:
    @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)
                }
            }
        }
    }
    jim

    jim

    1 year ago
    🤦
    cc @nickbutcher
    nickbutcher

    nickbutcher

    1 year ago
    d

    Denis

    1 year ago
    I did not. Nick, thank you for fixing it! And Jim thanks for your help too 😃