Trying to make the simplest react form hook
npm install --save @milkyweb/use-formor
yarn add @milkyweb/use-formInside another hook or your component:
const { register, handleSubmit } = useForm()After the useForm initialization, you can use the register function to define new fields. This
function returns 3 objects, e.g:
const { props, isTouched, errors } = register('name')- The
propsobject must be passed to the form field. isTouchedturns into true when the user first touches the fields- And
erroris an object containing possible errors
<input name='lastname' type='text' {...props} />GNUv3 © x0y-gt