I'm getting a crash when doing this: ```val items ...
# compose
s
I'm getting a crash when doing this:
Copy code
val items = viewModel.items.collectAsState(initial = listOf())
LazyColumn {
    items(items.value.size) { index ->
        ...
    }
}
But if I do
val items = viewModel.items.collectAsState(..).value
and
items(items.size)
, it works fine. Why doesn't the first snippet work?
s
My question is about the state
c
oh ok sorry for the quick response what i meant is the methods were moved around so it’s maybe not using the one you expected
k
Why you're passing
items.size
to
items() when
you can use
itemsIndexed()
👍 1