Skip to content

TCA holds on to state for longer than expected #3046

Closed Answered by stephencelis
pfandrade asked this question in Q&A
Discussion options

You must be logged in to vote

@pfandrade This is a behavior of SwiftUI navigation: when a screen is presented and dismissed, often times the destination view and state are kept around in memory till the next presentation. You can take our vanilla SyncUps app that uses plain old observable models and add this to SyncUpFormModel and you'll see the same behavior:

deinit {
  print("DEINIT")
}

And the behavior is reproducible in much simpler apps, as well.

So I do not think you should depend on the lifetime of objects held in the view graph being tied to the lifetime of views on the screen, and instead you can depend on other, more predictable hooks.

Since this isn't a bug in TCA, and is just vanilla SwiftUI behavior, I'm …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pfandrade
Comment options

Answer selected by pfandrade
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
Converted from issue

This discussion was converted from issue #3045 on May 05, 2024 16:41.