-
Hello :) I have a root view (TabView), with AppState’s store, and each of the tabs is the scope of state to its local one. But, whenever I’m receiving any action, the whole body of the root view is recreated, and, as a result, each view creates one more time. How to deal with this? I added debug to my app reducer, and on first tab switch, I see something like this: received action: ✅ FridgesFeatureView init And this is why I’m catching exceptions: Thread 1: Fatal error: The store was sent the action AppAction.recipesTab(.onAppear) while it was already This can happen for a few reasons:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you are seeing too many views created/computed then it probably means your So what you can do is |
Beta Was this translation helpful? Give feedback.
If you are seeing too many views created/computed then it probably means your
WithViewStore
could be focused on a smaller set of state. For example, in the screenshot you posted you haveWithViewStore(self.store)
, but then it seems that you aren't actually accessing any state fromviewStore
. That means the view will be recomputed any time actions are sent even though the state is never actually used to compute the body of the view.So what you can do is
.scope
your store so that it holds only the pieces of state you care about. In this case you don't actually care about any state, and so you can useWithViewStore(self.store.stateless)
.