Open Prince2k3 opened 2 years ago
I have the same problem. Even reloading the view (via network request and @Published
property) causes tabs to reset and navigation stacks to pop. Changing it to @StateObject
indeed fixed the problem for me. Please check out my fork if this works for you.
Only "downside" is forcing the library to iOS 14 as minimum version.
it does work! You should use the #available
to continue support iOS 13
Following up with some more info after some more investigations.
For me the TabView
refreshed because all of the underlying state was reloaded. I have a similar setup to example project (MainCoordinator -> TabCoordinator -> other coordinator). I tried many things which didn't work, the MainCoordinator always reloaded when app was switched to background and back. To cut it short, the culprit was a scenePhase
observer (.onChange
) on the view. So please check if you have something similar in your project as this could be the problem.
My main init is just
var body: some Scene {
WindowGroup {
MainCoordinator().view()
}
}
and it works great with current package version without my StateObject
changes.
I hope this helps.
When running my app using TabCoordnatable I noticed that when either pulling down control/Notification Center or getting a popup to confirm a purchase. That the tabs reset. My thoughts are that child property should be a StateObject when it is current an ObservedObject.