Simon
03/27/2021, 9:04 AMComposeview
inside each, but I'm facing an issue with state restoration when using navigation component. When put on the backstack, the fragment's view is destroyed, but onSaveInstanceState
is not called and there is no saveHierarchyState
mechanism on ComposeView
. So when a fragment's view is recreated when i pop the backstack, all scroll state of LazyColumn is lost for example. Is there a way to save this state inside fragments ? ThanksAndrey Kulikov
03/27/2021, 2:57 PMandroidx.fragment:fragment:1.3.2
Ian Lake
03/27/2021, 9:30 PMIan Lake
03/27/2021, 9:31 PMSimon
03/29/2021, 9:11 AM1.3.2
of Fragments and the latest beta of Compose. The CompositionLocal LocalSaveableStateRegistry
is indeed using FragmentViewLifecycleOwner
when a DisposableSaveableStateRegistry
is created.Andrey Kulikov
03/29/2021, 9:18 AMSimon
03/29/2021, 9:18 AMDisposableEffect
s created when using rememberSaveable
are disposed, so all the entries of the registry are removed, then the SaveableStateRegistry
is unregistered from the FragmentViewLifecycleOwner
and finally performSave is called, but there is nothing left to be savedSimon
03/29/2021, 9:35 AMVadim
04/29/2021, 4:32 PMIan Lake
04/29/2021, 4:42 PMsetViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
on your `ComposeView`: https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/AbstractComposeView#setviewcompositionstrategy https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyedSimon
04/29/2021, 4:52 PMsetViewCompositionStrategy
solved the issueVadim
04/29/2021, 4:53 PM