i'm implementing a little app with new iOS framework SwiftUI. I'm using @EnvironmentObject to bind my data to view. All works, but the Canvas crash and not show nothing. Why?
struct CompetitionsListSwiftUIView : View {
    @EnvironmentObject var competitionsViewModel: CompetitionsViewModel
    var body: some View {
        List(self.competitionsViewModel.competitions.identified(by: \.id)) { competition in
                CompetitionCellSwiftUIView(competition: competition)
            }
    }
}
#if DEBUG
struct CompetitionsListSwiftUIView_Previews : PreviewProvider {
    static var previews: some View {
        CompetitionsListSwiftUIView()
    }
}
#endif
The error message of the Canvas is this:
Error Domain=render service Code=12 "Rendering service was interrupted" UserInfo={NSLocalizedDescription=Rendering service was interrupted}
                Try adding your environment object to the preview:
#if DEBUG
struct CompetitionsListSwiftUIView_Previews : PreviewProvider {
    static var previews: some View {
        CompetitionsListSwiftUIView()
          .environmentObject(CompetitionsViewModel())
    }
}
#endif
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With