Skip to content

Latest commit

 

History

History
108 lines (78 loc) · 5.06 KB

README.zh-TW.md

File metadata and controls

108 lines (78 loc) · 5.06 KB

高效能、靈活、易擴充、易於使用的表單

npm downloads npm npm Coverage Status

Tweet Join the community on Spectrum

React Hook Form Logo - React hook form validation

English | 繁中 | 簡中 | 日本語 | 한국어 | Français | Italiano | Português | Español | Русский | Deutsch | Türkçe

功能

安裝

$ npm install react-hook-form

連結

快速開始

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

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

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstname" ref={register} /> {/* register an input */}
      <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>
  );
}

贊助者


想在這裡秀你的 Logo 嗎?在 Twitter 上私訊我

支持者

感謝所有支持者! [成為支持者]

組織機構

感謝這些優質的組織! [捐助]

貢獻者

感謝這些出色的人! [成為貢獻者]