📋 React Hooks for form state management and validation (Web + React Native)
MIT License
Published by bluebill1049 over 5 years ago
React Hook Form return a new formState: Object
which contain the following information
dirty
: when user interactive any fieldstouched
: what are the fields have interactedisSubmitted
: whether the form have been triggered with submittingexample:
const { formState: { dirty, touched, isSubmitted} } = useForm();
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
name
is supplied during register
Published by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
isSubmitted
with useEffect
Published by bluebill1049 over 5 years ago
watch()
fields no longer trigger validation error with onSubmit
modePublished 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
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
Published by bluebill1049 over 5 years ago
watch()
issuePublished by bluebill1049 over 5 years ago
Published by bluebill1049 over 5 years ago
usage:
https://codesandbox.io/s/6j1760jkjk
basically: you can assign array into input/select name
<input type="test" name="firstName[0]" />
<input type="test" name="firstName[1]" />
Published by bluebill1049 over 5 years ago
onDomRemove
event listeners on fieldsPublished by bluebill1049 over 5 years ago
textarea
as string input field