title: Update TabView and move to Home View after login
body: <p>I have the fllowing TabViews in the ContentView. For the onAppear, it works fine. However, I am trying also to reload the tabs and move to the home after the user login from LoginView.</p>
  
  <p>Following is the code of the ContentView</p>
  
  <pre><code>//  ContentView.swift
  //  Matjri
  //
  
  //
  
  import SwiftUI
  
  struct ContentView: View {
      @ObservedObject var user = User()
  
      var body: some View {
          HStack{
              if (user.tokenIsActive) {
                  TabView {
                      HomeView()
                          .tabItem {
                              VStack {
                                  Image(systemName: "house")
                                  Text("Home")
                              }
                      }.tag(0)
  
                      UserPostsView()
                          .tabItem {
                              VStack {
                                  Image(systemName: "person.fill")
                                  Text("Me")
                              }
                      }.tag(1)
  
                      NewPostView()
                          .tabItem {
                              VStack {
                                  Image(systemName: "plus")
                                  Text("Add")
                              }
                      }.tag(2)
                      SearchView()
                          .tabItem {
                              VStack{
                                  Image(systemName: "magnifyingglass")
                                  Text("Search")
                              }
                      }.tag(3)
                  }
              } else {
                  TabView {
                      HomeView()
                          .tabItem {
                              VStack {
                                  Image(systemName: "house")
                                  Text("Home")
                              }
                      }.tag(0)
  
                      LoginView()
                          .tabItem {
                              VStack {
                                  Image(systemName: "person.fill")
                                  Text("Me")
                              }
                      }.tag(1)
  
                      SearchView()
                          .tabItem{
                              VStack{
                                  Image(systemName: "magnifyingglass")
                                  Text("Search")
                              }
                      }.tag(2)
                  }
              }
  
          }
          .onAppear() {
              self.checkLoginValidity()
          }
      }
  
      func checkLoginValidity() {
  
          let userLogged = UserDefaults.standard.object(forKey: "userIsLogged") as? Bool ?? false
  
          if (userLogged) {
              let existinLogin = UserDefaults.standard.object(forKey: "loginExpiry") as! Date
  
              if (existinLogin &gt; Date().addingTimeInterval(86400 * 2)){
                  self.user.tokenIsActive = true
  
              } else {
                  self.user.tokenIsActive = false
              }
          } else {
              self.user.tokenIsActive = false
          }
      }
  }
  
  struct ContentView_Previews: PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  </code></pre>
  
  <p>When the user login from the LoginView, I set the tokenIsActive to true</p>
  
  <pre><code>struct LoginView: View {
  
      @ObservedObject var user = User()
  
      ........
  
      //Login successful
  
      self.user.tokenIsActive = true
  </code></pre>
  
  <p>TabView is not updating. How can I achieve this and I move the user to the homeview after login.</p>