PreCompose icon indicating copy to clipboard operation
PreCompose copied to clipboard

Navigation restarts when host Fragment gets restored

Open Miha-x64 opened this issue 1 year ago • 1 comments

If we're inside a Fragment, ComposeView gets destroyed when we're put to back stack and re-created when popped back. Under these circumstances remember() forgets everything but rememberSaveable() still works. https://github.com/Tlaster/PreCompose/blob/32bf75fb5e0f8ef3ac8cd06db6e18e52a040cf14/precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/NavHost.kt#L95-L97 LaunchedEffect() relies on remember(). Thus, navigation gets restarted, and even rememberSaveable() are useless inside destinations.

Miha-x64 avatar Jun 18 '24 09:06 Miha-x64

It might be better to find a new way to initialize the route graph, currently PreCompose still want to reset the route graph when builder or initial Route changed.

Tlaster avatar Jun 19 '24 02:06 Tlaster