use-form-coolhatguy
v1.1.6
Published
A starter for creating a new React hook
Downloads
7
Readme
useFormHook
a hook for form handling and vaildation that uses yup as a helper dependency
to import:
import { useForm } from "use-form-coolhatguy"
arguements:
1. intialState: initial state of the form
2. schema: yup schema for validating the form
returns:
[
form, // state of the form object
handleChange, // handles chenge of input by taking event property
reset, // reset function for reseting form to intial state
error, // error object that details errors
disabled, // boolean that tells whether the form should be diabled or not
]
Form Component
to import:
import { Form } from "use-form-coolhatguy"
props:
1. intialState: initial state of the form
2. schema: yup schema for validating the form
2. submit: function that takes formstate and runs on submit
return:
error messages and inputs. the type of input is decided by how the key value is name. If the key name includes "password" or "email" then that type of input will be rendered.
current input types accepted:
["password", "date", "time", "number", "color", "email"]