.if(_:then:)

... there is yet another problem beyond animations. When you use applyIf with a view that contains a State property, all state will be lost when the condition changes. ๐Ÿ‘‰ objc.io

In SwiftUI, views are structs which means that they don't have identity. For SwiftUI to animate changes, it needs to compare the value of the view before the animation started and the value of the view after the animation ends. SwiftUI then interpolates between the two values.

... the outermost type is a _ConditionalContent. This is an enum that will either contain the value from executing the if branch, or the value from executing the else branch. ๐Ÿ‘‰ objc.io

Last updated