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

More than 1 year has passed since last update.

Reactでevent.target.valueして知ったこと

Last updated at Posted at 2023-06-23

ReactでAPIを使用した簡単なアプリを作成しています。
その中で学んだことを自分が後で見返せるように書き残します。

onChange

onChangeイベントには最初からeventが付いてる。
非推奨の方を書いても動いたがvscode上でeventに取り消し線が引かれて非推奨表示が出た。

推奨

function handleChange(event) {
  console.log(event.target.value);
}

<input type="text" onChange={handleChange} />

非推奨

function handleChange(event) {
  console.log(event.target.value);
}

<input type="text" onChange={(event) => handleChange(event)} />
0
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?