Skip to content

Commit 1b1355c

Browse files
authored
Fix retain cycle in PresentationModifier (#2697)
1 parent 2c316f6 commit 1b1355c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/ComposableArchitecture/SwiftUI/PresentationModifier.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,12 @@ public struct PresentationStore<
285285
? toID($0).map { AnyIdentifiable(Identified($0) { $0 }) }
286286
: nil
287287
},
288-
compactSend: {
288+
compactSend: { [weak viewStore = self.viewStore] in
289289
guard
290+
let viewStore = viewStore,
290291
$0 == nil,
291-
self.viewStore.wrappedValue != nil,
292-
id == nil || self.toID(self.viewStore.state) == id
292+
viewStore.wrappedValue != nil,
293+
id == nil || self.toID(viewStore.state) == id
293294
else { return nil }
294295
return .dismiss
295296
}

0 commit comments

Comments
 (0)