From 12e01c11dbce125f54c11e273f87c7688cff67b2 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 13 Oct 2025 10:53:11 -0700 Subject: [PATCH] Add delay to child dismissal By immediately `nil`-ing out the child store, SwiftUI can misbehave in a number of ways. This PR attempts to fix #3789, #3783, #3779. --- Sources/ComposableArchitecture/Store.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/ComposableArchitecture/Store.swift b/Sources/ComposableArchitecture/Store.swift index 5058be61ceed..fbc345890180 100644 --- a/Sources/ComposableArchitecture/Store.swift +++ b/Sources/ComposableArchitecture/Store.swift @@ -343,7 +343,9 @@ public final class Store: _Store { .sink { [weak self, weak parent] _ in guard let scopeID = self?.scopeID else { return } - parent?.removeChild(scopeID: scopeID) + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) { + parent?.removeChild(scopeID: scopeID) + } } receiveValue: { [weak self] _ in guard let self else { return } self._$observationRegistrar.withMutation(of: self, keyPath: \.currentState) {}