title: Changing @State variable does not update the View in SwiftUI
body: <p>I have a following View (took out irrelevant parts):</p>
  
  <pre><code>struct Chart : View {
      var xValues: [String]
      var yValues: [Double]
      @State private var showXValues: Bool = false
  
      var body = some View {
          ...
          if showXValues {
              ...
          } else {
              ...
          }
          ...
      }
  }
  </code></pre>
  
  <p>then I wanted to add a way to modify this value from outside, so I added a function:</p>
  
  <pre><code>func showXValues(show: Bool) -&gt; Chart {
      self.showXValues = show
      return self
  }
  </code></pre>
  
  <p>so I build the Chart view from the outside like this:</p>
  
  <pre><code>Chart(xValues: ["a", "b", "c"], yValues: [1, 2, 3])
      .showXValues(true)
  </code></pre>
  
  <p>but it works as if the value was still false. What am I doing wrong? I thought updating an @State variable should update the view. I am pretty new to Swift in general, more so to SwiftUI, am I missing some kind of special technique that should be used here?</p>