Register Input with useForm.

Normally when we want to make a form we should think about which approach we are going to use; controlled or uncontrolled or debounce input. When we use useForm we can make the three aproach the same way, it is possible because useform has a function to register inputs and that function can make all kinds of input.


input function

The input function registers an input HTML tag. You can pass input tag or input name and type properties respectively.

import {useForm} from 'useforms'
const [{values, reset, onSubmit},{input}] = useForm({onChange:true, initialValues})
<input {...input({name:"input-name", type:"text", required:true ....})}>
<input {...input("input-name", "text")}>

custom function

The custom function registers a custom component like Custom Selects, Custom DatePiker. Custom inputs change your internal state every time the onChange event is dispatched, this means the custom function not support uncontrolled inputs.

import {useForm} from 'useforms'
const [{values, reset, onSubmit},{custom}] = useForm({onChange:true, initialValues})
<CustomINput {...custom("custom-select")}>