Hi again! I'm running into a problem with lists. I...
# compose
a
Hi again! I'm running into a problem with lists. I have a remembered
mutableStateOf()
a mutable list of strings. I'm just using a forEach inside a column to display the items.
Copy code
messageList.forEach {Text(it)}
However, I don't seem to see any updates on the screen when the list gets a new item (The list is updated via a coroutine scope fetching data from elsewhere). I put a
println()
to debug, and the list definitely changes in size - so I think I must be doing something wrong
t
Maybe it is because you're using
mutableStateOf
with a mutable list? You might have to use either one of these two instead:
var list with mutableStateOf(immutableList)
OR
val list with mutableStateListOf(initialData)
In the first case, you'd have to reassign
list
since its immutable, but in the second case, you wouldn't have to do that because
list
is mutable.
👍 2
a
Thanks, knew I was missing something right in front of me...
👍 1