title: Cannot use instance member 'dateType' within property initializer; property initializers run before 'self' is available
body: <p>I'm quite new to SwiftUI and can't get around this error.
  I'm trying to use two @State variables (isGlobal and dataType) in another array within the same initializer.</p>
  <p>I keep getting the error:
  &quot;Cannot use instance member 'dateType' within property initializer; property initializers run before 'self' is available&quot; and
  &quot;Cannot use instance member 'isGlobal' within property initializer; property initializers run before 'self' is available&quot;</p>
  <p>This is the code at the beginning of the view:</p>
  <pre><code>struct Home : View {
  @State var dateType : Int
  @State var isGlobal = true
  
  @State var dailyVax = [
      
      DailyVaccinations(day: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: false, dayCt: 6))&quot;, value: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: true, dayCt: 6))&quot;, show: true),
      DailyVaccinations(day: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: false, dayCt: 5))&quot;, value: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: true, dayCt: 5))&quot;, show: false),
      DailyVaccinations(day: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: false, dayCt: 4))&quot;, value: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: true, dayCt: 4))&quot;, show: false),
      DailyVaccinations(day: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: false, dayCt: 3))&quot;, value: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: true, dayCt: 3))&quot;, show: false),
      DailyVaccinations(day: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: false, dayCt: 2))&quot;, value: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: true, dayCt: 2))&quot;, show: false),
      DailyVaccinations(day: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: false, dayCt: 1))&quot;, value: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: true, dayCt: 1))&quot;, show: false),
      DailyVaccinations(day: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: false, dayCt: 0))&quot;, value: &quot;\(showData(tabType: isGlobal, date: dateType, dataType: 4, change: true, dayCt: 0))&quot;, show: false),
  ]
  
  var body: some View { ...
  </code></pre>
  <p>Here's the [DailyVaccinations] struct:</p>
  <pre><code>struct DailyVaccinations : Identifiable {
  var id = UUID().uuidString
  var day : String
  var value : String
  var show : Bool
  </code></pre>
  <p>}</p>
  <p>And here's the code that actually uses the &quot;dailyVax&quot; array:</p>
  <pre><code>ForEach(dailyVax.indices,id: \.self){i in
                          
                          
                          GraphView(data: dailyVax[i], allData: dailyVax)
                              .onTapGesture {
                              
                                  withAnimation{
                                      
                                      for index in 0..&lt;dailyVax.count{
                                          dailyVax[index].show = false
                                      }
                                      dailyVax[i].show.toggle()
                                  }
                                  
                              }
                          
                          if dailyVax[i].value != dailyVax.last!.value {
                              Spacer(minLength: 0)
                          }
                          
                      } ...
  </code></pre>
  <p>If anyone can help me solve this issue it would be greatly appreciated! thank you</p>