// Before I was able to do something like:
struct ContentView: View {
@EnvironmentObject var listData: ListData
var body: some View {
ListView($listData.listDataArray)
}
}
struct ListView: View {
@Binding var listDataArray: [DataType]
}
class ListData: ObservableObject {
@Published var listDataArray: [DataType] = []
}
// Now, I will get the error "Cannot find '$listData' in scope" on the line indicated below when I try to migrate to the Observable macro
struct ContentView: View {
@Environment(ListData.self) var listData
var body: some View {
ListView($listData.listDataArray) ----------> Error
}
}
struct ListView: View {
@Binding var listDataArray: [DataType]
}
@Observable
class ListData {
var listDataArray: [DataType] = []
}
@main
struct SomeApp: App {
@State private var listData = ListData()
var body: some Scene {
WindowGroup {
ContentView
.environment(listData)
}
}
}