Skip to content

Commit

Permalink
Merge pull request #115 from arkivanov/fix-compose-ui-state-not-resto…
Browse files Browse the repository at this point in the history
…red-on-configuration-change

Fix Compose UI state not restored on configuration change
  • Loading branch information
arkivanov authored Apr 15, 2021
2 parents a2e74ec + 8efa70a commit 7f8f31e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.arkivanov.decompose.extensions.compose.jetbrains
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.SaveableStateHolder
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
Expand All @@ -21,7 +20,7 @@ fun <C : Any, T : Any> Children(
animation: ChildAnimation<C, T> = { state, childContent -> childContent(state.activeChild) },
content: ChildContent<C, T>
) {
val holder = key(routerState) { rememberSaveableStateHolder() }
val holder = rememberSaveableStateHolder()
val state by routerState.asState()

holder.retainStates(state.getConfigurations())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.SaveableStateHolder
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
Expand All @@ -22,7 +21,7 @@ fun <C : Any, T : Any> Children(
animation: ChildAnimation<C, T> = { state, childContent -> childContent(state.activeChild) },
content: ChildContent<C, T>
) {
val holder = key(routerState) { rememberSaveableStateHolder() }
val holder = rememberSaveableStateHolder()
val state by routerState.asState()

holder.retainStates(state.getConfigurations())
Expand Down

0 comments on commit 7f8f31e

Please sign in to comment.