Skip to content

UseJsonFormOptions ​

The options of useJsonForm.

Definition ​

  • UseJsonFormOptions
    • builder SchemaBuilder: optional, builds the schema and knows your own types and rules. Defaults to createSchemaBuilder()
    • components FieldComponents: optional, your component for each field type
    • layoutComponents LayoutComponents: optional, your component for each layout type
    • validate ValidationMode: optional, when a field is validated the first time, as in Formisch
    • revalidate Exclude<ValidationMode, 'initial'>: optional, when it is validated again, as in Formisch

Example ​

ts
// Built once, outside the component: the builder is read on the first render.
const builder = createSchemaBuilder({ extensions: [affects()] })

export function useOrderForm(definition: JsonForm) {
  const jsonForm = useJsonForm(definition, {
    // Your own types, rules, messages and extensions. Defaults to createSchemaBuilder().
    builder,
    // Your component for each field type.
    components,
    // Your component for each layout type.
    layoutComponents,
    // When a field is validated the first time, and again after that, as in Formisch.
    validate: 'blur',
    revalidate: 'input',
  })
  return jsonForm
}

Hooks ​