Skip to content

Box @Fetch* property wrappers in SwiftUI state when possible#486

Open
stephencelis wants to merge 2 commits into
mainfrom
swiftui-state
Open

Box @Fetch* property wrappers in SwiftUI state when possible#486
stephencelis wants to merge 2 commits into
mainfrom
swiftui-state

Conversation

@stephencelis

Copy link
Copy Markdown
Member

There are some bugs with how the @Fetch* family of property wrappers behave when view identity throughout the hierarchy changes, forcing the Fetch* child value to be reconstructed in a bad state. E.g. a parent view might have some @State driving a @Binding in a child view that also has a @FetchAll, and changing that @State can cause the @FetchAll to be inert and not render in the view.

A fix for this has been to hold onto @FetchAll in @State, but nested property wrappers are cumbersome to use, and in Xcode 27 it's not even possible due to @State becoming a macro.

So instead, let's bake the @State directly inside the @Fetch*, preserving the data as the view hierarchy evolves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant