SwiftUI Bug may cause issues in TCA with any .task that you have (or .onAppear, .onDisappear, etc...)
#1913
Replies: 3 comments 3 replies
-
|
Have noticed this as well and this keeps us from using |
Beta Was this translation helpful? Give feedback.
-
|
@oliverfoggin Thanks for posting this... I'm seeing the same issue you described (in a very similar context where my tab bar is only presented to logged in users). Curious as to wether you found a decent workaround (I haven't had much luck so far), or just stopped using TabView altogether 🤔 |
Beta Was this translation helpful? Give feedback.
-
|
Bumping this as this basically makes TabViews unusable with a switch store setup for log in and log out. Using onAppear to start effects is basically a requirement at this point. Has anyone found any solutions or workarounds for this. The ability to start an effect when the view appears and not just the first time is critical. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have raised this as a bug with Apple.
FB11763863We make use in our app of the
.taskview modifier to trigger subscriptions to certain caches and endpoints that we have in the app. And similarly, we do things in.onAppearand.onDisappear.Before I understood what this bug was we had an issue where a user would log out of the app and we would clear any cached data. But when logging back in with a separate user (this is all in our debug env) the cache would still have old data from the old user.
I traced it down to the fact that our
.tasks were being run at the wrong time.Here is a quick example that highlights the problem
The problem exists for any apps that use a
TabViewand then at some point in the life of the app theTabViewis removed from the hierarchy.In this example, you can "log in" to the app. This will then show the tab view. When you switch between the tabs you can see the various
onAppear,onDisappear, andtasklogs.However, when you then tap "log out" you will again see all the
onAppear,onDisappear, andtaskof any of the views that you had previously opened but are no longer the current tab.This meant that our log out was clearing the cache but then SwiftUI was causing all our subscription caches would fetch new data and also send actions into their respective view stores which causes a huge rush of incoming purple warnings from TCA.
Something to keep an eye out for.
Beta Was this translation helpful? Give feedback.
All reactions