React Form Libraries

Demonstrates the use of form inputs using a third party react form library.

By default, form input components leverage the browser’s formdata event and constraint validation API . However you can easily use the inputs components in conjunction with a React form library. In this context, you are no longer using the browser’s default capabilities but are instead relying on the library in question to handle form data and validation events. This means you will need suppress client side validation by adding novalidate to the surrounding <form > element.

The following example demonstrates using form inputs with React Hook Form . Since the library itself is responsible for validation, you will see that novalidate is added to the form element and that the errorText property is leveraged to pass in the appropriate error message when it’s present.

As shown below, for some components you will need to leverage the Controller to ensure the onChange and onBlur events are mapped correctly to the form.

Search