google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.43k stars 598 forks source link

Pager state doesn't preserve the state after activity recreation #1440

Closed stevan-milovanovic closed 1 year ago

stevan-milovanovic commented 1 year ago

Pager state doesn't preserve the state if it is declared inside of the composable function with rememberPagerState.

With each recreation of the composable containing pagerState new pagerState was created, which triggered snapshotFlow collection and I received value 0 because of that, even though value should have been different.

I mitigated this issue with logic of storing pagerState in the view model, but since rememberPagerState implementation uses rememberSaveable I would assume that it should survive activity recreation, but this doesn't seem to be the case.

andkulikov commented 1 year ago

Hey. Yes, it should work. Could you please provide a reproducible sample?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.