Skip to content

Unnecessary recomputes of Views #694

Answered by mbrandonw
AndreiVidrasco asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @AndreiVidrasco, this is happening because you are observing more state than necessary in your views. The exact same thing would happen in vanilla SwiftUI too if you had a big ole observable object holding the state for multiple screens.

The fix is to scope the store when applying ViewStore so that you can chisel away the state to the bare essentials that the view needs to do its job. There are some examples of this in the case studies (e.g. here), and there are lots of examples of this in our isowords codebase.

For your example in particular, the DemoView doesn't actually need any state from the view store. It just needs to send actions. So you can use the .stateless property on Store

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AndreiVidrasco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants