NavigationView inside TabVIew gives to many calls on .onAppear and .onDisappear

Originator:aarsland
Number:rdar://FB8820127 Date Originated:10/22/2020
Status:Open Resolved:
Product:SwiftUI Product Version:xcode 12.1
Classification:Bug Reproducible:Always
 
.onApper and .onDisappear is called in an unexpected way if it is used inside a NavigationView under TabView. See output from provided code example. Tested on iOS 14.0 and 14.1

```
    var body: some View {
        TabView(){
            NavigationView{
                Text("Page One")
                    .navigationBarTitle("Page One: \(selectedIndex)")
                    .onAppear(perform: {
                        print("[Appear]: Page One")
                    })
                    .onDisappear(perform: {
                        print("[Disappear]: Page One")
                    })
                
            }
            .tabItem {
                Image(systemName: "1.circle")
                Text("Page 1")
            }
            NavigationView {
                Text("Page Two")
                    .onAppear(perform: {
                        print("[Appear]: Page Two")
                    })
                    .onDisappear(perform: {
                        print("[Disappear]: Page Two")
                    })
                    .navigationBarTitle("Page Two: \(selectedIndex)")
            }
            .tabItem {
                Image(systemName: "2.circle")
                Text("Page 2")
            }
        }
    }
```

On start up it will print: 
```
[Appear]: Page One
[Disappear]: Page One
[Appear]: Page One
``` 

Expected output: 
```
[Appear]: Page One
``` 

When the user clicks tab 2 - The output is: 
```
[Appear]: Page Two
[Disappear]: Page Two
[Appear]: Page Two
[Disappear]: Page One
``` 

Expected output: 
``` 
[Appear]: Page Two
[Disappear]: Page One
``` 

After the first visit on each tab, they will start function as expected.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!