@@ -202,14 +202,22 @@ public struct _NavigationDestinationViewModifier<
202202 content
203203 . environment ( \. navigationDestinationType, State . self)
204204 . navigationDestination ( for: StackState < State > . Component. self) { component in
205- navigationDestination ( component: component)
205+ destination ( store . scope ( component: component, fileID : fileID , filePath : filePath , line : line , column : column ) )
206206 . environment ( \. navigationDestinationType, State . self)
207207 }
208208 }
209+ }
209210
210- @MainActor
211- private func navigationDestination( component: StackState < State > . Component ) -> Destination {
212- let id = store. id (
211+ @_spi ( Internals)
212+ public extension Store {
213+ func scope< ChildState, ChildAction> (
214+ component: StackState < ChildState > . Component ,
215+ fileID: StaticString = #fileID,
216+ filePath: StaticString = #filePath,
217+ line: UInt = #line,
218+ column: UInt = #column
219+ ) -> Store < ChildState , ChildAction > where State == StackState < ChildState > , Action == StackAction < ChildState , ChildAction > {
220+ let id = self . id (
213221 state:
214222 \. [
215223 id: component. id,
@@ -222,8 +230,8 @@ public struct _NavigationDestinationViewModifier<
222230 )
223231 @MainActor
224232 func open(
225- _ core: some Core < StackState < State > , StackAction < State , Action > >
226- ) -> any Core < State , Action > {
233+ _ core: some Core < StackState < ChildState > , StackAction < ChildState , ChildAction > >
234+ ) -> any Core < ChildState , ChildAction > {
227235 IfLetCore (
228236 base: core,
229237 cachedState: component. element,
@@ -238,7 +246,7 @@ public struct _NavigationDestinationViewModifier<
238246 actionKeyPath: \. [ id: component. id]
239247 )
240248 }
241- return destination ( store . scope ( id: id, childCore: open ( store . core) ) )
249+ return self . scope ( id: id, childCore: open ( self . core) )
242250 }
243251}
244252
0 commit comments