Skip to main content

Context data

Some components might need to know a current form state, which is passed as React context. Properties stored in the context relates either to the form values or the form instance itself. That means, besides current form state, you can access form methods or encounter some metadata, e.g. about the used schema. Some of them were designed for internal use, but you can still take advantage of them.

Accessing context data

A direct way of accessing the context data is to use the useForm hook:

import { useForm } from 'uniforms';

function Example() {
const context = useForm();

For convenience, it's also accessible through the useField hook:

import { useField } from 'uniforms';

function Example(rawProps) {
const [props, context] = useField(, rawProps);

Available context data


Indicates whether there was a change on form.


A map of changed fields. Rather internal one, used for checking if other fields has changed.


An object with a details field, which is an array of any validation errors.


Contains reference to the form component that gives access to the form methods.


An object with current form fields values structured {field: value}.


It is an array of the parent fields names:

<Field name="x">
// name = []
<Field name="y.z">
// name = ['x']
<Field name="a" /> // name = ['x', 'y', 'z']

For example if we define a CompositeField:

const Composite = () => (
<AutoField name="firstName" />
<AutoField name="lastName" />

And use it like that:

<AutoForm schema={schema}>
<CompositeField name="personA" />
<SubmitField />

The name array of the nested AutoFields will store a personA value.


You can directly access to the onChange method. E.g. onChange(field, value).


Access to onSubmit method.


Access to randomId method, created using the randomIds() helper.


A bridge class instance with schema and validator properties.

The schema is simply your schema object and validator is your validating function.


The state is an object representing your current form status.

The state properties are:

disabledIndicates whether the form is disabled.
readOnlyIndicates whether the form is read-only.
showInlineErrorIndicates whether the inline errors should be shown.


Indicates whether the form was submitted.


Indicates whether the form is in the submitting state. Helpful when handling asynchronous submission.


Indicates whether the form is in the validating state. Helpful when handling asynchronous validation.