Here's an example:
@Composable
fun MyList(items: List<Item>) {
val lazyListState = rememberLazyListState()
lazyListState.layoutInfo // Accessing this field causes MyList to recompose infinitely
LazyColumn(state = lazyListState) {
itemsIndexed(items) { _, item ->
MyItem(item)
}
}
}
Why does accessing layoutInfo
causes MyList
to recompose infinitely? What am I doing wrong here?