Hi all, I have a very strange problem with my `Laz...
# compose
m
Hi all, I have a very strange problem with my
LazyColumn
. I am updating the menuList
State
in the ViewModel, the view recomposes but the debugger gets to LazyColumn and then stops, which means the children aren’t redrawn with the new data. Any ideas why? Thanks! MyView:
Copy code
val menuList = viewModel.menuData.observeAsState()

LazyColumn() {
                items(menuList.value.size) { i->
                    MenuItem(menuList.value[i])
                }
}
MyViewModel:
Copy code
private var menu: MenuUiState? = null
val menuData: SingleLiveEvent<MenuUiState> by lazy { SingleLiveEvent() }

// ...
menu?.sections?.forEach {
    //update menu properties here
}
menuData.value = menu?.copy()
l
check your menuList size in log
m
the data is definitely there. the debugger doesn’t even get to the
items(){}
line to check the size
c
I've had a ton of issues with compose + debugger. It's anecdotal at this point but I have been recluded to using logs instead of debugger in my compose apps.
m
I also tried that.. nothing after
LazyColumn() {
is printed
a
You can try using
items(menuList.value)
or
itemsIndexed(menuList.value)
if you really need indices.
The state has changed, but if the size does not change, I believe your
items
block will not be executed.