From my question that was answered here, I'm now not able to figure out how to make Canvas work when there's an @Binding
in the struct. My variation is now this toy code:
struct RootView: View {
@Binding var thingToUse: Thing
var body: some View {
// body code that compiles without error
}
}
struct RootView_Previews: PreviewProvider {
static var previews: some View {
var thingToPreview = Thing() // ERROR
RootView(thingToUse: thingToPreview)
}
}
This one gives the error, "Cannot convert value of type 'Thing' to expected argument type 'Binding'". Wrapping the preview's var with @Binding
doesn't make sense either. I tried anyway and got, "Cannot declare local wrapped variable in result builder." Other stuff I've tried doesn't compile, which means I still don't fully comprehend the logic here. How do I make that preview compile?