title: SwiftUI having @Environment(\.presentationMode) for dismissing view misbehaving
body: <p>I have a view with <code>@Environment(\.presentationMode) var presentationMode: Binding&lt;PresentationMode&gt;</code> for a custom dismiss action based on a published value around some logic like this:</p>
  <pre><code>.onAppear(perform: {
              viewModel.cancellable = viewModel.$shouldPopBack.sink(receiveValue: { shouldPopBackToHome in
                  if shouldPopBackToHome {
                      presentationMode.wrappedValue.dismiss()
                  }
              })
          })
  </code></pre>
  <p>This view also has another option to present a sheet</p>
  <pre><code>Button(action: {
              shouldNavigateToQRCodeScanner = true
          }, label: {
              Text(&quot;Scan QR code&quot;)
                  .padding(.horizontal)
          }).sheet(isPresented: $shouldNavigateToQRCodeScanner, content: {
              QRCodeScannerView()
          })
  </code></pre>
  <p>The problem here is when I have <code>@Environment(\.presentationMode)</code> the <code>QRCodeScannerView</code> is been initialized twice, when I remove the presentationMode it works fine.</p>
  <hr />
  <p><strong>Update</strong>
  I've tried the same behaviour in a test project and it's the same</p>
  <pre><code>struct ContentView: View {
  
  @Environment(\.presentationMode) var presentationMode: Binding&lt;PresentationMode&gt;
  @State var isPresentd: Bool = false
  
  var body: some View {
      NavigationView {
          Button(action: {
              isPresentd = true
          }, label: {
              Text(&quot;Navigate to Second View&quot;)
          })
          .sheet(isPresented: $isPresentd, content: {
                  SecondView()
              })
      }
  }
  
  }
  struct SecondView: View {
  
  init() {
      print(&quot;Initialized&quot;)
  }
  
  var body: some View {
      Text(&quot;Second View&quot;)
  }
  }
  </code></pre>
  <p>It has the same issue</p>
  <p><a href="https://i.stack.imgur.com/QpbtQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QpbtQ.png" alt="Screenshot" /></a></p>