Namig Tahmazli
03/20/2021, 3:18 PM@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 1.0.0-beta02
aiidziis
03/20/2021, 3:21 PMmutableListOf
to mutableStateListOf
?Adam Powell
03/20/2021, 3:22 PMAdam Powell
03/20/2021, 3:23 PMitems
to be an immutable reference to a mutableStateListOf
then you'll be back in business for nowAdam Powell
03/20/2021, 3:23 PMval items by remember { mutableStateListOf(1, 2, 3) }
which means you won't be able to reassign items
in the click listener, but editing its contents should be reflected as expected.Namig Tahmazli
03/20/2021, 3:28 PM