Is it okay to pass the ViewStore of a SwiftUI View directly to an inner subview, or is it better to pass the outer view's Store to the subview and then create a new ViewStore there? Assume for the sake of this question that the subview needs the same state/actions as the outer view so that the store doesn't need to be scoped. What's the best practice for this scenario?
It's definitely ok to do this, and it's something I do for simple leaf views that I extract out of a larger view. Eventually you may need to refactor to have the view take a proper
Store, like if you don't want changes to the child to cause the parent to re-render or if you want to make a full domain (state/action/env/reducer) for the child.
If you want to observe
ViewStore state changes, make sure to store it as an
@ObservedObject in the subview.