LoginSignup
0
0

More than 3 years have passed since last update.

react-hook-form Tips

Last updated at Posted at 2020-11-02

空のForm

バックエンド用に値が必要なときなどに使えます
asにフラグメントを置くところがポイント。

<Controller
  name={'id'}
  as={<></>}
  defaultValue={1}
/>

初期値の参照

useFormで指定した初期値を後から参照することができます。
control経由で取得。

const methods = useForm({defaultValues: 1});
console.log(methods.control.defaultValuesRef.current) //1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0