Both view modifiers that can be used to run some code when a view is shown but there are some differences between them. In general, .task() is more powerful and convenient but only available in iOS 15 or later.
You typically use State and StateObject to hold data as single source of truth, then passing around using binding, custom environment values, or preferences.
When using SwiftUI, you can individually animate changes to views, or to a view’s state, no matter where the effects are. SwiftUI handles….
Use view modifiers to indicate which views can receive focus, to detect which view has focus, and to programmatically control focus state.
You display a modal presentation, like an alert, popover, sheet, or confirmation dialog to draw attention to an important narrowly scoped task.
SwiftUI ships with a handful of property wrappers that enable us to declare exactly how our data is observed, rendered and mutated by our views.
Preparing for a SwiftUI interview involves a combination of learning the fundamental concepts of SwiftUI and practicing building user interfaces with the framework.