I am trying to search for my users that are saved in firebase but when I click on the user, my app crash and I receive this error
Thread 1: Simultaneous accesses to 0x6000031ad8d0, but modification requires exclusive access
What does this error mean and how do I fix this code to remove this error ?
@State private var searchText = ""
@StateObject var viewModel = SearchViewModel()
var body: some View {
NavigationStack{
ScrollView{
LazyVStack(spacing: 12){
ForEach(viewModel.users ) { user in
NavigationLink(value: user) {
HStack{
Image("Logo")
.resizable()
.scaledToFill()
.frame(width: 40, height: 40)
.clipShape(Circle())
VStack(alignment: .leading){
Text(user.username)
.fontWeight(.semibold)
}
Spacer()
}
.padding(.horizontal)
}
}
.padding(.top, 8)
.searchable(text: $searchText, prompt: "Search...")
}
.navigationDestination(for: User.self, destination: { user in
ProfileView(user: user)
})