How do I scroll Lazy list to 0th index when there’s new item added, updated or deleted to the list?
I’ve currently LaunchedEffect with notes as key but when I come to note list screen from note detail (without creating, updating or deleting the item) it scrolls the list to 0th position regardless of data changed or not?
@Composable
fun NoteList(notes: List<Note>, onItemClick: (String) -> Unit) {
val listState = rememberLazyListState()
LaunchedEffect(key1 = notes) { // when any item changes, scroll list to 0th index
listState.animateScrollToItem(0)
}
}