We may come across use cases where we need to load data asynchronously when a view appears. SwiftUI introduced task(_:) modifier in iOS 15 that provides an option to run an asynchronous task when the view appears and cancels it once the view disappears.
1