Created
August 30, 2023 13:12
-
-
Save chriseidhof/4fc103a9ca99a5ac733a36faead282b6 to your computer and use it in GitHub Desktop.
OnAppearVsTask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State private var color0 = Color.red | |
@State private var color1 = Color.red | |
var body: some View { | |
VStack { | |
color0 | |
color1 | |
} | |
.onAppear { color0 = .green } | |
.task { color1 = .green } | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment