1

In Compose ui HorizontalPager when scroll is call page content 2 times this mean if you in first page and scroll to second one page content will call two time.

HorizontalPager( pageCount = tabs.size, state = pagerState, modifier = Modifier.fillMaxSize() ) { val layoutPath = tabs[it].let { it.section.layout + it.section.path } // it = 1 // it = 2 SectionUi(layoutPath = layoutPath, tabs[it]) }

i try use launch effect , it fine but i will call api to get each section data with same ui but diff data per page

LaunchedEffect(pagerState){ snapshotFlow { pagerState.currentPage }.distinctUntilChanged().collect{ val layoutPath = tabs[it].let { it.section.layout + it.section.path } Log.d("snapshotFlow",layoutPath) } }`

0 Answers0