-
Notifications
You must be signed in to change notification settings - Fork 307
Open

Description
I have a pretty simple feature:
public struct MaintainFeature: ReducerProtocol {
public struct State: Equatable {
// This is the domain we're working on here.
var profile: Profile
var personalData: PersonalDataFeature.State?
var educations: EducationsFeature.State?
}
public enum Action: Equatable {
case didSelect(MaintainRoute?)
case personalData(PresentationAction<PersonalDataFeature.Action>)
case educations(PresentationAction<EducationsFeature.Action>)
...
}
public var body: some ReducerProtocol<State, Action> {
Reduce { state, action in
switch action {
case .didSelect(let route):
switch route {
case .personalData:
state.personalData = .init(personalData: state.profile.personalData)
return .none
case .educations:
state.educations = .init(educationList: state.profile.educationList)
return .none
case .none:
fatalError("Unsupported option")
}
...
case .personalData(_):
return .none
...
case .dismiss:
return .none
case .educations(_):
return .none
...
}
}
.ifLet(\.personalData, action: /Action.personalData) {
PersonalDataFeature()
}
.ifLet(\.educations, action: /Action.educations) {
EducationsFeature()
}
}
and a pretty simple view:
struct MaintainView: View {
let store: StoreOf<MaintainFeature>
var body: some View {
WithViewStore(store) { vs in
List {
Button {
vs.send(.didSelect(.personalData))
} label: {
Text("Personal Data")
}
Button {
vs.send(.didSelect(.educations))
} label: {
Text("Educations")
}
}
.navigationDestination(
store: self.store.scope(
state: \.personalData,
action: MaintainFeature.Action.personalData
), destination: { substore in
PersonalDataView(store: substore)
}
)
.navigationDestination(
store: self.store.scope(
state: \.educations,
action: MaintainFeature.Action.educations
), destination: { substore in
EducationsView(store: substore)
}
)
}
.navigationTitle("Maintain")
}
}
together with the Navigation.swift
content from your #228 episode, and the "navigation-beta" branch of TCA.
What's happening now is: nothing. It seems that the view is not triggered when a button is tapped, although the state is changed. The .navigationDestination code is not called, nor is the view redrawn.
Is this a bug or am I doing something wrong?
mortifactor
Activity
stephencelis commentedon Mar 30, 2023
@innoreq Are you using the tools that ship with the
navigation-beta
, or just the tools built during the episodes so far inNavigation.swift
? Also, what version of Xcode are you running, and what OS are you targeting?ghost commentedon Mar 30, 2023
stephencelis commentedon Mar 30, 2023
@innoreq We can take a look later, but if you could attach a full, compiling repro that would be helpful.
I will say though that
navigationDestination
is not without its bugs, and we'd recommend trying to reproduce the issue with vanilla SwiftUI to see if the bug exists there, too.