[iOS, SwiftUI] onAppear called twice on a NavigationView in a TabView
iOS 14.x
- onAppear called twice on a NavigationView in a TabView
TabView {
NavigationView {
Color.red
.onAppear {
print("appear : red")
}
.onDisappear {
print("disappear : red")
}
}
}
appear : red
disappear : red
appear : red
iOS 15.0
onAppear called twice on a NavigationView in a TabView
issue is resolved on iOS15, but onAppear of a ZStack in a NavigationView in a TabView is called twice
TabView {
NavigationView {
ZStack {
Color.red
.onAppear {
print("appear : red")
}
.onDisappear {
print("disappear : red")
}
}
}
}
appear : red
disappear : red
appear : red
Leave a comment