Skip to content
Discussion options

You must be logged in to vote

Own opinion:

When adding Text("Page: \(page) to the content view, the whole view gets redrawn. I assume @State is smart in that it knows that it should not re-render the view body, just because a binding is used. It seems to have a mechanism inside the $bindings it emits that allows certain Apple views to listen to changes, be it through a private publisher or through using @Binding inside a sub-view of TabView, that then emits the state change to change the page. When the state variable page is accessed directly the @State knows that it cannot track what was accessed, and so rerenders the body completely.

I think this tracking of "accessed directly at all" is a step between tracking what…

Replies: 2 comments 20 replies

Comment options

You must be logged in to vote
16 replies
@GreatApe
Comment options

@GreatApe
Comment options

@fabstu
Comment options

@GreatApe
Comment options

@GreatApe
Comment options

Comment options

You must be logged in to vote
4 replies
@GreatApe
Comment options

@GreatApe
Comment options

@GreatApe
Comment options

@fabstu
Comment options

Answer selected by GreatApe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants