title: How do I update a List in SwiftUI?
body: <p>My code is a little more complex than this so I created an example that gets the same error.</p>
  
  <p>When I navigate into a view, I have a function I want to perform with a variable passed into this view. That function then produces an array. I then want to put that array into a List, but I get an error.</p>
  
  <p>How do I get the List to show the produced array?</p>
  
  <p>I think the issue is the List can't be updated because it already has the declared blank array.</p>
  
  <pre><code>struct ContentView : View {
  
      @State var array = [String]()
  
      var body: some View {
          List(self.array,id: \.self) { item in
              Text("\(item)")
              }
              .onAppear(perform: createArrayItems)
      }
  
      func createArrayItems() {
          array = ["item1", "item2", "item3", "item4", "item5"]
      }
  
  }
  </code></pre>