SwiftUI reload TabView Tabs not properly

Hi,

I've trying to implement a Bottom Bar Navigation with SwiftUI where each tab fetches some related data.
The problems are mainly two:
  1. Each time I select a tab, the parent who contain the TabView get reloaded

  2. If I chose the third tab (for instance), the first and second tab gets reloaded ( and fetch remote data again…)

I don't get if it's a TabView bugs or I am doing something wrong…

Code Block
struct HomeView: View {
    @EnvironmentObject var authenticatedUser : AuthenticatedUser
    @State private var selectedIndex = 0    
    var body: some View {
        TabView(selection: self.$selectedIndex) {
                MyProfileView()
                    .tabItem { Image(systemName: "person") }
.tag(0)
                DashboardView()
                    .font(.title)
                    .tabItem { Image("archivebox") }
                    .tag(1)
                TopTrendsView()
                    .font(.title)
                    .tabItem { Image("square.grid.3x3") }
                    .tag(2)
                MyAccountView()
                    .font(.title)
                    .tabItem { Image("gearshape") }
                  .tag(3)
            }.tabViewStyle(DefaultTabViewStyle())
        }
}



I've tried with both XCode 12 beta 4 and XCode 11


You can easily work around the problem by binding to TabView selection and setting the current tab manually like so:


Code Block
struct ContentView: View {
@State private var currentTab = 0
var body: some View {
TabView(selection: $currentTab)
{
TabAView()
.tabItem({Text("Tab A")})
.tag(0)
.onAppear() {
self.currentTab = 0
}
TabBView()
.tabItem({Text("Tab B")})
.tag(1)
.onAppear() {
self.currentTab = 1
}
}
}
}

im having the same issue with children views of the parent tab vies. anyone have a solution so that the views dont redraw everytime the tab is switched
SwiftUI reload TabView Tabs not properly
 
 
Q