title: SwiftUI: how to update a variable transiting from a parent view only when wanted?
body: <p>I would like to pass a variable from a parent to a child view, but in this child view, use it in a text field but update this value only when a SAVE button is pressed.</p>
  <p>I tried this:</p>
  <p><strong>ParentView</strong></p>
  <pre><code>struct ParentView: View {
      @State private var name: String = &quot;&quot;
      
      var body: some View {
          HStack {
              Text(&quot;User name: \(name)&quot;)
              Spacer()
              NavigationLink(
                  destination: ChildView(name: name),
                  label: {
                      Text(&quot;Update name&quot;)
                  }
              )
          }
      }
  }
  </code></pre>
  <p><strong>ChildView</strong></p>
  <pre><code>struct ChildView: View {
      @State private var name: String = &quot;&quot;
      @Binding var passedName: String
      
      var body: some View {
          VStack {
              Form {
                  TextField(&quot;Update name&quot;, text: $name)
                  Button(action: {
                      passedName = name
                  }, label: {
                      Text(&quot;SAVE&quot;)
                  })
              }
          }
      }
      
      init(name: String) {
          self._passedName = .constant(name)
          self.name = name
      }        
  }
  </code></pre>
  <p>Since I don't want to update the variable directly, I tried to use a <code>name</code> value and then only set the value of the binded <code>passedName</code> when the OK button is tapped. But it doesn't work.</p>
  <p>I don't know how to do what I want to.</p>
  <p>Thank you for your help</p>