Skip to content

Add: hold a binding as @Binding, not a plain stored property - #76

Merged
AvdLee merged 1 commit into
AvdLee:mainfrom
larryonoff:add-binding-not-plain-property
Jul 24, 2026
Merged

Add: hold a binding as @Binding, not a plain stored property#76
AvdLee merged 1 commit into
AvdLee:mainfrom
larryonoff:add-binding-not-plain-property

Conversation

@larryonoff

@larryonoff larryonoff commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Adds a ### Declare a Binding with @Binding, Not a Plain Property subsection under ## @Binding (plus a matching Key Principles entry).

Why: a binding held in an undecorated property (let x: Binding<T>) is invisible to SwiftUI tracking — only DynamicProperty properties are subscribed to — so external changes don't re-evaluate the view. Distinct from the existing "don't use @Binding for read-only" note: here the developer wants reactivity but declares it wrong. Often a Release-only failure; hits UIViewRepresentable hardest.

Docs-only, ToC unchanged (new heading is ###, like the sibling @Binding subsections).

Test notes: verified a view storing let selection: Binding<Item?> didn't re-evaluate on external reset in Release; @Binding var selection: Item? fixed it.

A binding stored in an undecorated property (let/var x: Binding<T>) is
invisible to SwiftUI's dependency tracking, because only DynamicProperty
properties are unwrapped and subscribed to. The view then fails to
re-evaluate when the bound value changes from elsewhere. Debug builds can
mask this with extra graph passes, so it often surfaces only in Release.

Adds a subsection under @binding and a matching Key Principles entry.
@larryonoff
larryonoff force-pushed the add-binding-not-plain-property branch from ee2c567 to 1b4d3b9 Compare July 3, 2026 10:47

@AvdLee AvdLee left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution!

@AvdLee
AvdLee merged commit eb3d484 into AvdLee:main Jul 24, 2026
@larryonoff
larryonoff deleted the add-binding-not-plain-property branch July 24, 2026 06:50
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.

2 participants