Declare Static var in SwiftUI #Preview macro

280 views Asked by At

I have the following code in SwiftUI preview macro.

  #Preview {
     @StateObject static var store = Store()
     ...
  }

And it fails with the error:

Static properties may only be declared on a type

Is there a solution for this?

0

There are 0 answers