React Hooks Form

React Hooks Form

  • Guides
  • Components
  • Hooks
  • Github

›Components

Getting Started

  • Overview
  • Usage

Guides

  • Organizing Your Fields
  • Client-side Validation
  • Server-side Validation
  • Input Components
  • Form Submission
  • Using Hooks

Components

  • <Form />
  • <FormField />

Hooks

  • useFormFieldValue
  • useFormFieldMeta
  • useFormValues
  • useFormMeta
  • useForm

<Form />

This is the component you need to build a form, basically you do this:

function SimpleForm() {
  function handleSubmit(data) {
    // Do something with data
  }

  return (
    <Form onSubmit={handleSubmit}>
      // fields...
    </Form>
  );
}

Props you can pass to <Form />

The following table shows the available props you can pass to Form component:

PropTypeDescription
namestringName your form
initialValuesobjectValues to initialize form with
enableReinitializeboolWhether to re-initialize the form every time initialValues changes. Default is false.
visitOnBlurboolMark the fields as visited when the field is blurred. Default is true.
visitOnChangeboolMark the fields as visited when the field is changed. Default is false.
onSubmitfuncREQUIRED! A function which receives form data and returns a Promise. Read more about onSubmit in Form Submission.
onSubmitCompletefuncFired whether form submission is successful or not
onSubmitFailfuncFired when submission fails
onSubmitSucceedfuncFired when submission succeeds
validatefuncA function which receives form data and returns the errors, if there are any invalid fields. Read more about validate in Client-side Validation.
destroyOnUnmountboolReset everything to initial state or not. Default is true.
← Using Hooks<FormField /> →
  • Props you can pass to <Form />
Docs
Getting StartedGuidesComponentsHooks
Community
Stack Overflow
More
Star
Copyright © 2019 Mehdi Namvar