I have this navigation directory where I need to pass in data to a view but I can’t get it to work. Any ideas?
This is my file for the router:
Todd
I have this navigation directory where I need to pass in data to a view but I can’t get it to work. Any ideas?
This is my file for the router:
Todd
In PatientList you have defined searchQuery
as @Binding var searchQuery: String
which means that you needy to pass in a variable from AppContainerView which matches that type.
In AppContainerView you have defined var searchQuery: Patient
. Is that what you intended?
Looking at your PatientList
it would appear that you have confirmed that you require searchQuery
to be a String
since you are filtering where $0.name
contains searchQuery
.
That being the case then in AppContainerVIew you need to have a @State variable defined as a String to pass in where the compiler is complaining that there is a missing argument. Your declaration ought to be @State var serachQuery = ""
since somewhere you should be setting that prior to calling PatientList. On that point, where are you going to set searchQuery?
The call site in AppContainerView where you have case .preSearch:
can now be
PatientList(searchQuery: $searchQuery)
I hope that all makes sense.
Note I’m moving your question to app development, because that’s where it best fits, not community