-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View not updating with shared store and form #3235
Comments
Your issue might be that you need to conform Action to BindableAction. And use Binding Reducer. enum Action: BindableAction {
case binding(BindingAction<State>)
}
var body: some Reducer<State, Action> {
BindingReducer()
Reduce { state, action in
switch action {
case .binding:
return .none
}
}
}
} |
Thanks for the suggestion and taking a look! In the actual app I am using |
Actually ran into another issue with a view not updating. This example is a bit simpler. Put together a simple todo app. Kind of a weird setup having the list send the |
Just jumping in to say I also experienced this issue. Here is a demo app I used for testing. Screen.Recording.2024-08-09.at.10.50.26.movIn my setup, I have a public mutating func toggle(id: RowFeature.State.ID) {
if let selectedItem = items[id: id] {
items[id: id] = selectedItem.with(isSelected: !selectedItem.isSelected)
}
} However, as shown in the video, while the |
I was able to fix it by replacing It seems like updating the element in the numbers array doesn't work but if you remove the old element and append the new one it does the trick: Simulator.Screen.Recording.-.iPad.10th.generation.-.2024-10-16.at.14.33.51.mp4 |
Description
I've hit a weird issue with the UI not updating. I am using a
NavigationSplitView
and the right and middle column share the same scoped store/state. A form/sheet is presented from the right column and on save the state in the parent reducer is properly updated. The UI in the right column is updated but the left is not.I reproduced the issue in a smaller sample app (use iPad) and have slowly been removing parts of it to help isolate the issue. I believe I've got it down to the smallest possible. In the sample I have removed the
NavigationSplitView
and just placed the two views embedded within a parent to simplify it a bit.Here is a video of the sample app. You can see on save the right view's "Sum" has been updated but the left column's has not. If you force an update via a local
@State
property the UI is correct. Also any other actions will trigger it to update as well.ViewNotUpdating.mov
Some observations:
Also if you add another property to the parent state other than the
@Presents form
and thenumbers
list and update it on the save it works.SumView
andNumberListView
into theSplitView
it works correctly.Admittedly I'm not sure if this is a bug in TCA or SwiftUI or I am doing something wrong since I am a bit rusty with TCA but everything seems correct as far as I can tell.
Checklist
main
branch of this package.Expected behavior
Both views should update
Actual behavior
Only the right column updates on the form
saveFormTapped
action.Steps to reproduce
Run the sample app.
The Composable Architecture version information
1.11.2
Destination operating system
iOS 17
Xcode version information
15.4
Swift Compiler version information
The text was updated successfully, but these errors were encountered: