Skip to content
RED SAGSkills
hard20 pts · first answer countsjetpack-composeperformance

derivedStateOf for a scroll button

A "scroll to top" button should appear once the list is scrolled. Why is derivedStateOf useful here?

val listState = rememberLazyListState()
val showButton by remember {
  derivedStateOf { listState.firstVisibleItemIndex > 0 }
}
Choose one answer