LoginSignup
0
0

More than 1 year has passed since last update.

ReactにおけるhtmlFor

Posted at

間違い例

Reactでlabelタグにforを設定するとエラーが表示されます。

App.tsx
      <label for="name">Name</label>
      <input id="name" type="text" />

原因

Javascriptの予約語のforと混同されるため

対応

下記の通りhtmlForに変更します。

App.tsx
      <label htmlFor="name">Name</label>
      <input id="name" type="text" />

classがclassNameとなるのと同様です。

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