I have created a Store declared as @MainActor
@MainActor
class Store{
var name = ""
}
Create an instance of it in code
@main
struct NewReduxTest2App: App {
let store = Store()
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
I got error: Call to main actor-isolated initializer 'init(initialState:environment:reducer:)' in a synchronous nonisolated context
If I replace the code with
@StateObject var store = Store()
The code can be executed correctly.
I don't understand why I have to use @StateObject to create this instance correctly.