Created
December 10, 2019 12:54
-
-
Save chriseidhof/3ad94375e536088638ea4dcd98e0a0a9 to your computer and use it in GitHub Desktop.
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
struct Nested: View { | |
@State var counter = 0 | |
init() { | |
print("Init") | |
} | |
var body: some View { | |
Button(action: { self.counter += 1 }, label: { | |
Text("Tap me! \(counter)") | |
}) | |
} | |
} | |
struct ContentView: View { | |
@State var counter = 0 | |
var body: some View { | |
VStack { | |
Button(action: { self.counter += 1 }, label: { | |
Text("Tap me! \(counter)") | |
}) | |
.padding() | |
.background(Color.orange) | |
.cornerRadius(5) | |
Nested() | |
} | |
} | |
} | |
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