Ok. I'm dumb as a stump and can't get a list to u...
# compose-desktop
t
Ok. I'm dumb as a stump and can't get a list to update. I've got a window with a lazycolumnfor, but when I update the remembered value, the ui doesn't update. im expecting theres a onUpdate or similar I'm missing. Can someone point me to a sample with a CRUD list?
t
Can u paste the code here?
BTW, there's no
onUpdate
kinda thing here.
t
Copy code
Box(modifier = Modifier.fillMaxSize())
{
    LazyColumnFor(
        modifier = Modifier.fillMaxSize(),
        items  = entries,
        state = scrollState,
        itemContent = { Text(it) }
    )
    VerticalScrollbar(ScrollbarAdapter(scrollState, entries.count(), 1f))
}
this function is being passed a List<String> of entries
t
and where do you update the value?
t
im seeing that im updating a copy of the object. let me sort that out and see if its a monday morning thing. 🙂
👍 1
o
I think you could also check the version of Java you're using. While I used 8 the UI doesn't update every time, but when I moved to 15, everything started to work.
t
I am using openjdk15 good to know though.
j
I find it highly unlikely that the JVM version would be causing the app to behave differently, but if the JVM version is causing the code to behave differently, that is a huge bug, please file a bug with a minimal repro.
Also, if you are mutating the list, be sure you are using a
SnapshotStateList
(probably via
mutableStateListOf
. Or ensure your list is immutable, but that is not recommended if the list is large as it will be more expensive to recompose on each change.
t
I've now had a chance to go back and apply the changes and use SnapshotStateList as suggested by Jim. I now have a working example and am back in motion making progress. Thanks for your help guys!