Available Actions
ATTENTION
As of JSON Forms 2.5 the React-Redux variant is deprecated in favor of the JSON Forms "standalone" component. See our migration guide for more information.
JSON Forms provides a couple of actions to interact with the store, which we describe here. All actions might either be imported directly or via the Actions utility.
init(data: any, schema: JsonSchema, uischema: UISchemaElement, options: InitActionOptions | AJV.Ajv)
#
APIThe INIT action expects the data, schema and UI Schema and initializes the store accordingly. Currently, this action must be called in order for JSON Forms to work properly.
The options
parameter allows customization of the validator and the ref resolver that are both used by JSON Forms.
update(path: string, updater: (existingData: any) => any
#
APIThe update action is used to update the data substate within the store.
It expects two arguments: a dot-separated path describing which part of the data should be updated as well as a function that returns the value that should be used.
The function gets passed the current value that might be used to calculate the updated value.
mapDispatchToControlProps
and mapDispatchToFieldProps
provide a helper function called handleChange
which already dispatches the update action, so that you rarely need to interact with update itself, if at all.
registerRenderer(tester: RankedTester, renderer: any)
#
APIThis action allows you to register a renderer. It expects two arguments, the 1st being a tester and the 2nd the actual renderer. Please see the section about Custom Renderers for an example how to use these.
registerUISchema(tester: UISchemaTester, uischema: UISchemaElement)
#
APIWhen initializing JSON Forms you have to provide a UISchema. Generally this is already enough as it covers most use cases. But in some cases, especially when rendering (nested) arrays, you have to provide an UISchema which can be retrieved. This allows you, for example, to customize the layouts for the elements of the array.
The registration of an UISchema looks as follows:
You can retrieve a registered UI schema via the findUISchema
function.
findUISchema(uischemas: object[], schema: JsonSchema, schemaPath: string, path: string, fallbackLayoutType?: string, control?: ControlElement, rootSchema?: JsonSchema)
To retrieve the registered UI schema you can call the 'findUISchema' function which is provided through the properties.
This function needs the UI Schemas (which consists of a tester and a UI schema), the schema, the schemaPath and a subpath. Optionals parameters are a fallback layout type (VerticalLayout
by default), a control and the root schema.
All those parameters are also passed through the properties. The usage is shown using a renderer.
unregisterUISchema(tester: UISchemaTester)
#
APIThis action allows to unregister a previously registered UI schema.