title: SwiftUI View flickering when displaying it based on State with if-else
body: <p>I want to display a certain form in the app based on a <code>Picker</code> selected value. However, when I switch using the segmented control fast enough (here it seems forced, but when the form is more complex it's very noticeable). Edit: this seems to be happening with all <code>View</code>s, not just forms.</p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      
      @State private var calculationType = CalculationType.months
      
      @State private var balanceOwned: String = &quot;&quot;
      
      var body: some View {
          VStack {
              Picker(&quot;Calculation Type&quot;, selection: $calculationType) {
                  ForEach(CalculationType.allCases, id: \.self) {
                      Text($0.rawValue.capitalized)
                  }
              }.pickerStyle(SegmentedPickerStyle())
  
              // This check seems to be the cause of the problem!
              if calculationType == .months {
                  CustomForm(balanceOwned: $balanceOwned)
              } else if calculationType == .fixed {
                  CustomForm(balanceOwned: $balanceOwned)
              } else {
                  CustomForm(balanceOwned: $balanceOwned)
              }
          }
      }
  }
  
  struct CustomForm: View {
      
      @Binding var balanceOwned: String
      
      var body: some View {
          Form {
              Section {
                  TextField(&quot;Test&quot;, text: $balanceOwned)
                      .foregroundColor(.white)
              }
          }
      }
  }
  
  enum CalculationType: String, CaseIterable {
      case months
      case fixed
      case minimum
  }
  </code></pre>
  <p>Whatever is inside the form flickers. How do I fix it?</p>
  <p><a href="https://i.stack.imgur.com/dMq08.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dMq08.gif" alt="" /></a></p>