I present this view as a sheet from its parent view
struct NamesView: View {
@Binding var match: Match
var body: some View {
...
}
}
Since the match
source of truth is in the parent view presenting this NamesView
sheet, when the view is constructed I pass in a $match
binding and data flows as intended.
However, when constructing this view in a preview provider
struct NamesView_Previews: PreviewProvider {
static var previews: some View {
NamesView()
}
}
the compiler says that NamesView()
expects a match
argument of type Binding<Match>
(Match
being the parent view presenting this view as a sheet). I'm not sure what would be a good way to proceed from here or if this is a limitation of SwiftUI.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…