Skip to main content

The AutoView Component

The AutoView React component is the main component of the AutoViews library. AutoView automatically render data that conforms to the given JSONSchema using the React components registered in The Components Repository (ComponentsRepo) and provided through The Repository Provider (RepositoryProvider).

Optionally, AutoView can use the UISchema (UISchema) to customize how to render the components - which components to use, at which order or using which groups.

Basic example of AutoView usage

<RepositoryProvider components={repo}>
<AutoView
schema={schema}
data={currentData}
uiSchema={uiSchema}
onClick={clickHandler}
/>
</RepositoryProvider>

Properties of the AutoView Component

For reference, the properties of the AutoView are defined as the interface AutoViewProps.

NameTypeDefault ValueDescription
schemaCoreSchemaMetaSchemaRequired The JSONSchema representing the data that should be rendered. See also the Data JSONSchema.
dataanyThe data property is the input to be rendered by AutoViews. data is optional, and if present should be valid against JSONSchema. If not valid and if the validation property is true, the onError callback will be called with a validation error.
uiSchemaUISchemaThe UISchema used to modify how the data is rendered.
validationbooleanfalseDefined if to validate the data against the schema. If the validation fails, the onError callback will be called with a validation error.
pointerstring''pointer is a JSONPointer string that defines what data part AutoView should render. By default the data root is rendered.
schemaPointerstring''schemaPointer is a JSONPointer string that defines what schema part AutoView should use for data rendering. By default the 'schema' root is used for rendering.
pickstring[][]Specifies an array of field names to render for object types.
omitstring[][]Specifies an array of field names to not render for object types.
onChangeAutoEventHandler <AutoChangeEvent>A data change event handler that components in the ComponentsRepo can invoke with JSONPatch over the data. See also Events.
onClickAutoEventHandler <AutoClickEvent>A click event handler that components in the ComponentsRepo can invoke with any data payload. See also Events.
onError(error:ValidationError) => voidCalled when validation is set and the data does not conform to the schema. See also Events.
onRenderError(error:ValidationError) => voidCalled if any child component throws an error during rendering. See also Events.
onCustomEventAutoEventHandler<AutoCustomEvent> A Custom event with payload of data and name for custom usage by components and applications. See also Events.
metadataMetadataA Map of JSONShema pointer to any payload that is passed to components. The utility getComponentMetadata can be used to extract the metadata by the schema pointer.
repositoryNamestringPassed to the components - The repository name is the component is registered with.
fieldstringPassed to the components - the field to be rendered.