Skip to content

Lifecycle

Use hooks to observe validation and submit phases:

mountForm(container, {
transport: createJsonTransport({ endpoint: "/api/predict" }),
schema,
hooks: {
beforeSubmit({ serializedValues }) {
console.log("Submitting", serializedValues);
},
afterSubmit({ result }) {
console.log("Reports", result.reports);
},
onSubmitError({ error }) {
console.error(error);
},
},
});

Use form validators for cross-field checks:

validators: [
({ values }) => {
if (values.min > values.max) {
return { fields: { max: ["Max must be greater than min."] } };
}
},
];

Always call mounted.unmount() when the host app tears down the view.