My return type is View on my function - my structs conform to View - Adding the extra step of wrapping in AnyView() is an additional step for what feels like it will be a common problem and also carries performance costs (see hackingwithswift.com/quick-start/swiftui/how-to-return-different-view-types).
Post
Replies
Boosts
Views
Activity
I guess this is just my lack of understanding of Swift UI, but "PopulatedHomeScreen and EmptyView are different types, there's no common ancestor type"
seems a strange given they both declare conformance to View
Although the approaches in the article would work, I would be interested to see if someone with more experience than myself has knowledge of a better approach as I assume this would be a common problem
I found the answer elsewhere
		@ViewBuilder
		 func fetchView() -> some View {
				if someDataState {
						PopulatedHomeScreen()
				} else {
						EmptyView()
				}
		}
}
thanks for checking out !