https://kotlinlang.org logo
#compose
Title
# compose
b

Brian Gardner

04/28/2020, 1:32 PM
@Leland Richardson [G] Ok, so I tried using the
state{}
to wrap the list but the
AdapterList
is still not updating when I change the data. I tried both
ReferentiallyEqual
and
StructurallyEqual
for the
state
parameter. I also tried moving the state down to the individual row views themselves. This does cause the row to update when the user interacts with it but if the item scrolls off screen and comes back on then it is composed with the old state since nothing told the list component to change the state. I'll do some digging into React to see what their best practices are for dealing with list state
A way I found to work around this is to pass a listener from my list component down to the individual row view. This listener is triggered by the row whenever the state changes so my list component will update that item. This makes the scrolling work but I don't think it's ideal
a

Andrew Neal

04/28/2020, 1:46 PM
This makes the scrolling work
Your
AdapterList
wasn't scrolling at all?
b

Brian Gardner

04/28/2020, 1:47 PM
Sorry, I should have been more clear. My
AdapterList
is scrolling (I'm currently on dev09) but my workaround keeps the row state the same when it scrolls off the screen then back on
a

Andrew Neal

04/28/2020, 1:57 PM
Huh, I gotcha. I wonder if you'll have better luck with the
dev10
release tomorrow. I know there are some updates to the way
AdapterList
disposes views offscreen in it, there was a commit in aosp within the last couple of weeks.
b

Brian Gardner

04/28/2020, 1:58 PM
I hope so! This workaround will suffice for now but I'm looking forward to the list updates working. I definitely have a lot more to learn about dealing with state with compose
l

Leland Richardson [G]

04/28/2020, 3:57 PM
ok, sounds like this is a legit bug with adapterlist then. thanks for trying it out and reporting back!