I ran into this on Xcode 12 Beta on Big Sur while following the SwiftUI tutorial: https://developer.apple.com/tutorials/swiftui/handling-user-input.
The fix that worked was to add .environmentObject on the preview.
Before:
struct LandmarkDetail_Previews: PreviewProvider {
static var previews: some View {
LandmarkDetail(landmark: landmarkData[0])
}
}
After:
struct LandmarkDetail_Previews: PreviewProvider {
static var previews: some View {
LandmarkDetail(landmark: landmarkData[0])
.environmentObject(UserData())
}
}