1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Warning: Received NaN for the 'value' attributeエラーの対処法

Posted at

はじめに

React + TypeScript + Chakra UI + Supabase を使った「学習記録アプリ」を Jest でテストする際に、実際に詰まったエラーと解決方法をまとめます。

2. Warning: Received NaN for the 'value' attribute

状況:

Chakra UIのNumberInputにNaNが渡されて警告が出た。

原因:

React Hook Form の Controller と数値入力の連携が不完全で、文字列と数値の変換が崩れた。

解決方法:

  • Controller に valueAsNumber: true を設定して数値として扱う。

  • defaultValue を必ず 0 や 1 に設定して初期値を明示する。

まとめ

数値入力には valueAsNumber と defaultValue を必ず設定。

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?