title: Removing View with EnvironmentObject causes crash (SwiftUI)
body: <p>I have an array of structs, which ForEach uses to generate SubViews. When I delete one of object from that array, one of SubViews disappear as expected. But when I pass an EnvironmentObject to the SubView and that view gets deleted, app crashes. By the way, its a Mac App.</p>
  <pre><code>import SwiftUI
  
  struct Item: Identifiable {
      var id = UUID().uuidString
      var title: String
  }
  
  class Data: ObservableObject {
      @Published var items: [Item] = [Item(title: &quot;One&quot;), Item(title: &quot;Two&quot;), Item(title: &quot;Three&quot;)]
      
      func removeOneItem (){
          if items.count &gt; 0 {
              items.remove(at: 0)
          }
      }
  }
  
  struct ContentView: View {
      @StateObject var data = Data()
      var body: some View {
          VStack {
              ForEach(data.items.indices, id:\.hashValue) { i in
                  SubView(item: $data.items[i]).environmentObject(data)
              }
              Button(action: data.removeOneItem) {Text(&quot;Remove one item&quot;).foregroundColor(.red)}
          }
      }
  }
  
  struct SubView: View {
      @Binding var item: Item
      @EnvironmentObject var data: Data  // &lt;- works only without this line
      var body: some View {
          Button { self.item.title = &quot;tapped&quot;} label: {Text(item.title)}
      }
  }
  </code></pre>
  <p>Any ideas?</p>