diff --git a/Sources/TCACoordinators/TCARouter/TCARouter.swift b/Sources/TCACoordinators/TCARouter/TCARouter.swift index 82243bb..d728d22 100644 --- a/Sources/TCACoordinators/TCARouter/TCARouter.swift +++ b/Sources/TCACoordinators/TCARouter/TCARouter.swift @@ -22,9 +22,13 @@ public struct TCARouter< func scopedStore(index: Int, screen: Screen) -> Store { let id = identifier(screen, index) + var screen = screen return store.scope( - state: { routes($0)[safe: index]?.screen ?? screen }, - action: { action(id, $0) } + state: { + screen = routes($0)[safe: index]?.screen ?? screen + return screen + }, + action: { action(id, $0) } ) } diff --git a/TCACoordinatorsExample/TCACoordinatorsExample/TCACoordinatorsExampleApp.swift b/TCACoordinatorsExample/TCACoordinatorsExample/TCACoordinatorsExampleApp.swift index 4f5e216..cd37d5a 100644 --- a/TCACoordinatorsExample/TCACoordinatorsExample/TCACoordinatorsExampleApp.swift +++ b/TCACoordinatorsExample/TCACoordinatorsExample/TCACoordinatorsExampleApp.swift @@ -23,27 +23,25 @@ struct MainTabCoordinatorView: View { let store: Store var body: some View { - WithViewStore(store) { _ in - TabView { - IndexedCoordinatorView( - store: store.scope( - state: \MainTabCoordinatorState.indexed, - action: MainTabCoordinatorAction.indexed - ) - ).tabItem { Text("Indexed") } - IdentifiedCoordinatorView( - store: store.scope( - state: \MainTabCoordinatorState.identified, - action: MainTabCoordinatorAction.identified - ) - ).tabItem { Text("Identified") } - AppCoordinatorView( - store: store.scope( - state: \MainTabCoordinatorState.app, - action: MainTabCoordinatorAction.app - ) - ).tabItem { Text("App") } - } + TabView { + IndexedCoordinatorView( + store: store.scope( + state: \MainTabCoordinatorState.indexed, + action: MainTabCoordinatorAction.indexed + ) + ).tabItem { Text("Indexed") } + IdentifiedCoordinatorView( + store: store.scope( + state: \MainTabCoordinatorState.identified, + action: MainTabCoordinatorAction.identified + ) + ).tabItem { Text("Identified") } + AppCoordinatorView( + store: store.scope( + state: \MainTabCoordinatorState.app, + action: MainTabCoordinatorAction.app + ) + ).tabItem { Text("App") } } } }