docs/README.ru-RU.md
</a>
</p>
</a>
</p>
<a href="./README.V6.md">English</a> | <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.de-DE.md">Deutsch</a> | <a href="./README.tr-TR.md">Türkçe</a>
$ npm install react-hook-form
import React from 'react';
import { useForm } from 'react-hook-form';
function App() {
const { register, handleSubmit, errors } = useForm(); // инициализация хука
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 && 'Фамилия обязательна.'}
<input name="age" ref={register({ pattern: /\d+/ })} />
{errors.age && 'Пожалуйста, введите ваш возраст.'}
<input type="submit" />
</form>
);
}
Спасибо всем кто поддерживает нас! [Стать спонсором].
<a href="https://opencollective.com/react-hook-form#backers"> </a>Спасибо этим замечательным организациям! [Спонсировать]
<a href="https://github.com/react-hook-form/react-hook-form/graphs/contributors"> </a>Спасибо этим замечательным людям! [Стать участником].
<a href="https://github.com/react-hook-form/react-hook-form/graphs/contributors"> </a>