Hi everyone. I am issuing one funky stuff with State and LazyColumn. Basically updating list item does not make the UI update right away but only after scrolling.
Copy code
@Composable
fun Test() {
var items by remember {
mutableStateOf(
mutableListOf(
1,
2,
3,
)
)
}
LazyColumn {
items(items) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.clickable {
val list = items
list[0] = 6
items = list // this does not make the list to recompose
items = mutableListOf(6,2,3) // this does not work either
items = mutableListOf(6,3,2) // this makes the list to recompose
},
contentAlignment = Alignment.Center,
) {
Text(text = it.toString(), fontSize = 50.sp)
}
}
}
}
If you know why or got an idea please let me know.
P.S. Compose version is