Code Block language struct PostLoginView: View { @StateObject var userLoader = FirestoreUser(uid: Auth.auth().currentUser!.uid, getUpdates: true) var body: some View { TabView(selection: $currentTab) { NavigationView{ UserProfileView(currentTab: $currentTab, userLoader: userLoader, postsLoader: postsLoader) .environmentObject(userSettings) }
This gets passed to other views where it is observed.
Code Block language struct UserProfileView: View { @ObservedObject var userLoader: FirestoreUser
Code Block language Group{ HStack { Spacer() NavigationLink(destination: ProfilePhotoUpdateView(userLoader: self.userLoader).environmentObject(self.userSettings)) { Image(systemName: "pencil").padding(.horizontal).font(Font.title.weight(.bold)) .foregroundColor(buttonStartColor) } }
This chain can continue for a few more links
If the model userLoader is updated in any way, the stack pops back automatically to the first view. This is not the desired behavior. How can I keep the current child view when the model is updated?