diff --git a/Sources/SkipUI/SkipUI/Containers/List.swift b/Sources/SkipUI/SkipUI/Containers/List.swift index d3cd49ee..72724d0f 100644 --- a/Sources/SkipUI/SkipUI/Containers/List.swift +++ b/Sources/SkipUI/SkipUI/Containers/List.swift @@ -115,10 +115,11 @@ public final class List : View { let refreshState: PullRefreshState? if let refreshAction { let refreshScope = rememberCoroutineScope() + let updatedAction = rememberUpdatedState(refreshAction) refreshState = rememberPullRefreshState(refreshing.value, { refreshScope.launch { refreshing.value = true - refreshAction() + updatedAction.value() refreshing.value = false } }) diff --git a/Sources/SkipUI/SkipUI/Containers/ScrollView.swift b/Sources/SkipUI/SkipUI/Containers/ScrollView.swift index a03ec7bb..f23600fa 100644 --- a/Sources/SkipUI/SkipUI/Containers/ScrollView.swift +++ b/Sources/SkipUI/SkipUI/Containers/ScrollView.swift @@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.Modifier import kotlinx.coroutines.launch #else @@ -65,10 +66,11 @@ public struct ScrollView : View { let refreshAction = EnvironmentValues.shared.refresh let refreshState: PullRefreshState? if let refreshAction { + let updatedAction = rememberUpdatedState(refreshAction) refreshState = rememberPullRefreshState(refreshing.value, { coroutineScope.launch { refreshing.value = true - refreshAction() + updatedAction.value() refreshing.value = false } })