Back to React Hook Form

README.V6

docs/README.V6.md

7.75.010.1 KB
Original Source
<div align="center"> <p align="center"> <a href="https://react-hook-form.com" title="React Hook Form - Simple React forms validation">
    </a>
</p>
</div> <p align="center">Performant, flexible and extensible forms with easy to use validation.</p> <div align="center">

</div> <div align="center"> <p align="center"> <a href="https://react-hook-form.com" title="React Hook Form - Simple React forms validation">
    </a>
</p>
</div>

English | <a href="./README.zh-TW.md">繁中</a> | <a href="./README.zh-CN.md">简中</a> | <a href="./README.ja-JP.md">日本語</a> | <a href="./README.ko-KR.md">한국어</a> | <a href="./README.fr-FR.md">Français</a> | <a href="./README.it-IT.md">Italiano</a> | <a href="./README.pt-BR.md">Português</a> | <a href="./README.es-ES.md">Español</a> | <a href="./README.ru-RU.md">Русский</a> | <a href="./README.de-DE.md">Deutsch</a> | <a href="./README.tr-TR.md">Türkçe</a>

Features

Install

npm install react-hook-form

Quickstart

jsx
import React from 'react';
import { useForm } from 'react-hook-form';

function App() {
  const { register, handleSubmit, errors } = useForm(); // initialize the hook
  const onSubmit = (data) => {
    console.log(data);
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstname" ref={register} />
      <input name="lastname" ref={register({ required: true })} />
      {errors.lastname && 'Last name is required.'}
      <input name="age" ref={register({ pattern: /\d+/ })} />
      {errors.age && 'Please enter number for age.'}
      <input type="submit" />
    </form>
  );
}

Sponsors

Thanks go to these kind and lovely sponsors (company and individuals)!

<a href="https://underbelly.is/" target="_blank"> </a> <p> <a href="https://github.com/sayav" ></a> <a href="https://github.com/lemcii" ></a> <a href="https://github.com/washingtonsoares" ></a> <a href="https://github.com/lixunn" ></a> <a href="https://github.com/SamSamskies" ></a> <a href="https://github.com/peaonunes" ></a> <a href="https://github.com/wilhelmeek" ></a> <a href="https://github.com/iwarner" ></a> <a href="https://github.com/joejknowles" ></a> <a href="https://github.com/chris-gunawardena" ></a> <a href="https://github.com/Tymek" ></a> <a href="https://github.com/Luchanso" ></a> <a href="https://github.com/vcarel" ></a> <a href="https://github.com/gragland" ></a> <a href="https://github.com/tjshipe" ></a> <a href="https://github.com/krnlde" ></a> <a href="https://github.com/msutkowski" ></a> <a href="https://github.com/mlukaszczyk" ></a> <a href="https://github.com/susshma" ></a> <a href="https://github.com/MatiasCiccone" ></a> <a href="https://github.com/ghostwriternr" ></a> <a href="https://github.com/neighborhood999" ></a> <a href="https://github.com/yjp20" ></a> <a href="https://github.com/samantha-wong" ></a> </p>

Backers

Thanks go to all our backers! [Become a backer].

<a href="https://opencollective.com/react-hook-form#backers"> </a>

Organizations

Thanks go to these wonderful organizations! [Contribute].

<a href="https://github.com/react-hook-form/react-hook-form/graphs/contributors"> </a>

Contributors

Thanks go to these wonderful people! [Become a contributor].

<a href="https://github.com/react-hook-form/react-hook-form/graphs/contributors"> </a>