I have a simple composable function which contains LazyColumn:
@Composable
fun MyScreen(itemList: List<Item>) {
LazyColumn {
intems(itemList) {
...
}
}
}
Everything works great, but my ViewState(itemList
) should change when the scroll reaches some position index. That's why I add the following lines to my composable function:
@Composable
fun MyScreen(itemList: List<Item>) {
val lazyListState = rememberLazyListState()
viewModel.onPositionChanged(lazyListState.firstVisibleItemIndex)
LazyColumn(state = lazyListState) {
intems(itemList) {
...
}
}
}
Everything works as I expected, but performance has noticeably deteriorated. How I can fix it?