I have a view showing error information which is working fine. The information is wrapped inside a struct. But I couldn’t figure out how to mock the expected data to show the view in preview canvas.
Struct to store the error information.
struct ErrorWrapper: Identifiable {
let id = UUID()
let error: Error
let guidance: String
let errorStyle: ErrorStyle
}
Preview with the missing part for the Error.
#Preview {
//how to instanciate an error?
static var errorWrapper = ErrorWrapper(error, "guidance", ErrorStyle.ok)
ErrorViewOk(errorWrapper: errorWrapper)
}
New contributor
MatFetsch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.