How to use @State to see changes in same view

import SwiftUI

struct ContentView: View {

    @State var firstname: String

    var body: some View {
        VStack(alignment: .center) {
            TextField("enter name", text: $firstname)

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView(firstname: "")


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s