Posts

Post not yet marked as solved
14 Replies
15k Views
I have a starting view that contains the StateObject created from an Observable Object. 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. struct UserProfileView: View {   @ObservedObject var userLoader: FirestoreUser 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?
Posted
by ardeploy.
Last updated
.