React form with Debounce Form


Debounce function forces a function to wait a certain amount of time before running again. The function is built to limit the number of times a function is called.

The debounce parameter delays the updating of the state until the user has stopped changing inputs for a predetermined amount of time.

The input value be set to state values and then updated via React events. Defining a form’s input value via state is considered a controlled component. For controlled inputs you will need a corresponding state and then a function to update that state with changes.

React Docs

It means that whenever state is changed the component, it is rendered again.

If you want to use this kind of form, you need only pass property debounce: number whit a time in object received in useForm hook.

Also, it means that the validations are run in every state change, providing better user feedback. See more in Controlled Inputs with validation.


useForm provides a register function, this function returns all properties to manager a field.

* initial Values optional
const initialValues = {
data1: 'test',
data2: 'test2',
complextData: [
first: 'testComplexData',
score: 45
const { state, register } = useForm({ initialValues, debounce: 300 })

Use dot notation to create advanced objects or to map object values. Type an entry name and type or an entry property object.

<input {...register("data1")}/>
<input {...register("complexData.0.first")}/>