title: SwiftUI [Presentation] / Attempt to present View on ... which is already presenting
body: <p>I am working on a SwiftUI app and am having warnings first and later bugs, probably because I ignored the warnings. I want to show the warnings I am getting and I hope somebody can point out something I may be doing wrong.</p>
  <p>Here is the relevant code:</p>
  <pre><code>struct CustomListView: View {
      var localList:[SomeManagedObject], moc:NSManagedObjectContext
      @State var showingOtherView = false
      
      func handleCustomItem(_ argument: SomeManagedObject) {
          print(#function)
          self.showingOtherView.toggle()
          ..... Do useful things .....
      }
      
      var body: some View {
          List {
              ForEach(self.localList) {
                  item in
                  HStack {
                      Spacer()
                      Button(action: {
                          self.handleCustomItem(item)
                      })
                      {
                          Text(item.expression!)
                              .foregroundColor(Color.red))
                              .font(.headline)
                              .padding(.horizontal, 11).padding(.vertical, 15)
                      }.sheet(isPresented: $showingOtherView) {
                          OtherView()
                      }
                      Spacer()
                  }
              }
          }
      }
  }
  </code></pre>
  <p>This is the code for OtherView:</p>
  <pre><code>import SwiftUI
  import CoreData
  
  struct OtherView: View {
  
      var body: some View {
          Text(&quot;Hello OtherView&quot;)
      }
  }
  </code></pre>
  <p>And these are the messages I can see in the debugging console, when I click one button in the list and execute the <em>handleCustomItem()</em> function :</p>
  <blockquote>
  <p>handleCustomItem(_:) 2021-04-20 22:53:10.667895+0900
  TheApp[9600:5758072] [Presentation] Attempt to present
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10529a510&gt; on
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10510a310&gt; (from
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10510a310&gt;) which is already presenting
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x105299150&gt;. 2021-04-20 22:53:10.668399+0900 TheApp[9600:5758072]
  [Presentation] Attempt to present
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10529b1b0&gt; on
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10510a310&gt; (from
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10510a310&gt;) which is already presenting
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x105299150&gt;. ........... 2021-04-20 22:53:10.670049+0900
  TheApp[9600:5758072] [Presentation] Attempt to present
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x105118e10&gt; on
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10510a310&gt; (from
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x10510a310&gt;) which is already presenting
  &lt;<em>TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView</em>:
  0x105299150&gt;.</p>
  </blockquote>
  <p>That would be great if one could see something and give me a hint on what I can do.</p>