title: List selection not changing value
body: <p>I want to change a <code>@State var</code> variable whenever a row in a list is being selected. Similar to what <code>didSelectRow</code> does in UIKit. That means when tapping on <em>&quot;One&quot;</em> the text on the right-hand side should change from <em>&quot;Nothing selected&quot;</em> to <em>&quot;One&quot;</em>.</p>
  <p><a href="https://i.stack.imgur.com/8e9tl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8e9tl.png" alt="enter image description here" /></a></p>
  <p>Here's my current implementation. However, tapping on a row does nothing at all.</p>
  <pre><code>struct ContentView: View {
      
      @State var items = [Item(id: 1, text: &quot;One&quot;), Item(id: 2, text: &quot;Two&quot;), Item(id: 3, text: &quot;Three&quot;)]
      @State var selectedItem: Item? = nil
      
      var body: some View {
          GeometryReader { geometry in
              HStack(alignment: .center) {
                  List(items, selection: $selectedItem) { item in
                      Text(item.text)
                  }
                  .frame(width: geometry.size.width / 2.5, height: geometry.size.height)
                  .listStyle(InsetGroupedListStyle())
                  
                  Text(selectedItem?.text ?? &quot;Nothing selected&quot;)
              }
          }
      }
  }
  
  struct Item: Identifiable, Hashable {
      var id: Int
      var text: String
  }
  </code></pre>
  <p>How can I change the text when someone taps a row?</p>