Skip to content
Discussion options

You must be logged in to vote

Hey @tgrapperon, yeah this is definitely tricky, but it is indeed how SwiftUI and TCA is expected to work, and this exact thing would happen in vanilla SwiftUI.

It's tripped me up a number of times, but you have to think of view modifiers applied to Group as being applied to every view inside. So:

Group {
  IfLetStore(...)
  IfLetStore(...)
}
.onAppear { ... }

Is really:

IfLetStore(...)
  .onAppear { ... }
IfLetStore(...)
  .onAppear { ... }

Further, IfLetStore is really just:

if condition {
  content
}

so your original code further transforms into something like this:

if condition {
  content
    .onAppear { ... }
}
if condition {
  content
    .onAppear { ... }
}

And so from this it bec…

Replies: 2 comments 1 reply

Comment options

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

Answer selected by tgrapperon
Comment options

You must be logged in to vote
0 replies
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 #801 on September 16, 2021 14:46.