Compose Navigation 3 changes how ViewModels are scoped compared to Navigation 2. By default, ViewModels are scoped to the Activity rather than individual navigation destinations, meaning init{} blocks only run once per app launch and state persists across screen re-entries. To restore per-destination scoping, you need to add the `androidx.lifecycle:lifecycle-viewmodel-navigation3` dependency and configure `NavDisplay` with `rememberSaveableStateHolderNavEntryDecorator()` and `rememberViewModelStoreNavEntryDecorator()`. An alternative is triggering data loads via `LaunchedEffect` in the UI layer, though stale state may still persist without entry-scoped ViewModels.

4m read timeFrom proandroiddev.com
Post cover image
Table of contents
Default behaviorScoping to a navigation entryGet Domen Lanišnik ’s stories in your inboxSummary

Sort: