useJsonForms
The primary hook for accessing JSON Forms state and dispatch function from within theJsonFormsStateProvider context.
Returns
The core JSON Forms state containing:
data- Current form dataschema- JSON Schemauischema- UI Schemaerrors- Validation errorsadditionalErrors- Additional validation errorsvalidator- Validation functionajv- Ajv instance
Available renderer registry entries
Available cell renderer registry entries
Configuration object
UI schema registry entries
Read-only mode flag
Internationalization state with locale and translation functions
Dispatch function for updating core state. Can be used to dispatch actions like:
Actions.init()- Initialize stateActions.update()- Update dataActions.updateCore()- Update core propertiesActions.setConfig()- Set configuration
Example
Usage in Custom Renderers
While HOCs are the recommended approach for most renderers, you can useuseJsonForms directly for more control:
Context Mapping Functions
These utility functions are used internally by HOCs but can also be used withuseJsonForms for custom state mapping:
ctxToControlProps
Maps context and own props to control props.ctxToLayoutProps
Maps context and own props to layout props.ctxToArrayControlProps
Maps context and own props to array control props.ctxToArrayLayoutProps
Maps context and own props to array layout props.ctxToCellProps
Maps context and own props to cell props.ctxToEnumControlProps
Maps context and own props to enum control props with memoized options.ctxToOneOfProps
Maps context and own props to oneOf combinator props.ctxToAnyOfProps
Maps context and own props to anyOf combinator props.ctxToAllOfProps
Maps context and own props to allOf combinator props.Dispatch Mapping Functions
Functions for mapping dispatch to props:ctxDispatchToControlProps
Creates dispatch props for controls.ctxDispatchToArrayControlProps
Creates dispatch props for array controls.ctxDispatchToMultiEnumProps
Creates dispatch props for multi-enum controls.Translation Hooks
withTranslateProps
HOC that injects translation props into a component.t- Translation functionlocale- Current locale string
withArrayTranslationProps
HOC that provides array-specific translations for array renderers.translations- Object with translated strings for array operations (add, remove, up, down, etc.)