useInputs with string

You can create an input state by passing a string as an argument. When you use a string, the input is VALID by default, because there is no validation attached to it. Please use it if :

  • You want an input that doesn't need validation
  • You want only one input that doesn't need validation

Import

Import useInputs from aio-inputs package

import{useInputs}from"aio-inputs"
Copied

Create your input

Call useInputs with the name you want. For example, you want the phoneNumber of a user.

const[myInput]=useInputs("phoneNumber")
Copied

myInput.phoneNumber contains these ready-to-use properties.

Now bind an input element.

<input{ ...myInput.phoneNumber.props }/>
Copied

That is it. The value entered by the user will be stored in phoneNumber.value.

Validity

To know if your form (all your inputs) is valid, use isValid property. Every input has also his own valid property

// all inputs
yourInputs.isTouched
yourInputs.isValid
// Each input
eachInput.touched
eachInput.valid
Copied

You can RESET or also get all VALUES by using the FORM OBJECT.

Hit next to find out how to use array with aio-inputs