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?

Reactイベントハンドラ命名慣習 handleSomething, onSomething

Last updated at Posted at 2025-02-16

自分用メモ

Reactイベントハンドラの一般的な命名規則

  • propsとして渡すイベントにはonSomething、イベントを処理するハンドラ関数にはhandleSomethingを使うことが一般的だそう。
const Children = ( { onButtonClick } ) => <button type="button" onClick={onButtonClick}>Button</button>

const Parent = () => {
    const handleClick = () => {
        console.log("clicked!");
    }

    return <Children onButtonClick={handleClick} /
}

このリンクの少し上の箇所

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?