I have simple app, when I run my project it work, but then throw error after running like "Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view."
Code Block struct Home: View { @EnvironmentObject var data : msgDatas var body : some View{ ZStack{ Color("bg").edgesIgnoringSafeArea(.top) NavigationLink(destination: Message(), isActive: $data.show) { Text("") } VStack{ topView() } } } }
I solve problem, when I calling @State
Code Block struct Home: View { @EnvironmentObject var data : msgDatas @State var show: Bool = false var body : some View{ ZStack{ Color("bg").edgesIgnoringSafeArea(.top) NavigationLink(destination: Chat(), isActive: self.$show) { Text("") } VStack{ topView() } } } }