I\'m building an app with SwiftUI. When I was trying to display a sheet (previously Modal), this error message appears:
Thread 1: Fatal error: No observable objec
You have to pass your environment object to BixiStationDetailView
, otherwise it won't have anything to bind to its @EnvironmentObject
.
.sheet(isPresented: self.$isModalOpen) {
BixiStationDetailView(station: self.station)
.environmentObject(self.bixiModel)
}
Since you're presenting BixiStationDetailView
as a sheet, it isn't a subview of your CardView
and therefore doesn't inherit its @EnvironmentObject
.