📋 React Hooks for form state management and validation (Web + React Native)
MIT License
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
the example below for integrating with react-select
https://codesandbox.io/s/72j69vnk1x
Published by bluebill1049 over 5 years ago
setValue
const setValue = (name: string, value: string | number | boolean) => void
example:
setValue('firstname', 'bill');
Published by bluebill1049 over 5 years ago
defaultValues
as optional argument for useForm
const { register, handleSubmit } = useForm({
defaultValues: {
firstName: "bill",
lastName: "luo",
email: "[email protected]"
}
});
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
setError
method for a dynamic set or clear errorset an error
set('firstname', 'required')
clear an error
set('firstname', undefined)
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
reset()
to reset field values and errorsPublished by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
isSubmittedRef
and submitCountRef
to be mutated after form submittedPublished by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
isSubmitting
submitCount
Published by bluebill1049 over 5 years ago
##Better typescript support
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
onBlur
and onChange
https://github.com/bluebill1049/react-hook-form/issues/23
Published by bluebill1049 over 5 years ago