.collectAsLazyPagingItems() recomposing composable
On using .collectAsLazyPagingItems() on a data type of Flow<PagingData<..>>.
It cannot stop the composable from recomposing one extra time.
Any solution or am I doing something fundamentally wrong
data class UIState(
val data: Flow<PagingData<..>>
)
# inViewmodel
_uiState = MutableStateFlow(UiState())
uiState = StateFlow<UIState> = _uiState.asStateFlow()
#in composable
@Composable
fun Container(){
//INIT LAUNCHED EFFECT
Screen(uiState=...,onstateEvent=..)
}
@Composable
fun Screen(
..
..
){
val data = state.scans.collectAsLazyPagingItems()
}
Source: View source