New in SwiftUI 3: Task in SwiftUI 3 and iOS 15

Task modifier was introduced in WWDC21 as part of iOS 15 release. Task modifier can be applied on any SwiftUI view and is another way(better way 😍) to start asynchronous task.

So, if you have been using onAppear to fetch data when your view appears then you can use task instead. Task modifier is more powerful and manages work state automatically so if your view unloads from memory while work is still underway, task takes care of cancelling itself automatically.