Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
知られざるprops命名の慣習 アクション編
Search
uhyo
August 27, 2025
Technology
3.5k
12
Share
知られざるprops命名の慣習 アクション編
2025-08-27 Findy TECH BATON「実践Next.js!AIアウトプットとコンポーネント設計」 最新事情 LT
uhyo
August 27, 2025
More Decks by uhyo
See All by uhyo
TypeScript 7.0の現在地と備え方
uhyo
7
2.5k
React 19時代のコンポーネント設計ベストプラクティス
uhyo
19
8.9k
型定義でAIと会話する:型を通じてAIに意図を伝えるテクニック
uhyo
1
66
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
3
1k
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
3
850
TypeScript 6.0で非推奨化されるオプションたち
uhyo
18
7.9k
Claude Code 10連ガチャ
uhyo
4
1.1k
AI時代、“平均値”ではいられない
uhyo
8
4.2k
意外と難しいGraphQLのスカラー型
uhyo
5
1.1k
Other Decks in Technology
See All in Technology
AWS認定資格は本当に意味があるのか?
nrinetcom
PRO
1
220
Introduction to Bill One Development Engineer
sansan33
PRO
0
410
サイバーフィジカル社会とは何か / What Is a Cyber-Physical Society?
ks91
PRO
0
190
インフラを Excel 管理していた組織が 3 ヶ月で IaC 化されるまで
geekplus_tech
3
190
2026年に相応しい 最先端プラグインホストの設計<del>と実装</del>
atsushieno
0
120
AWS DevOps Agentはチームメイトになれるのか?/ Can AWS DevOps Agent become a teammate
kinunori
1
190
新規サービス開発におけるReact Nativeのリアル〜技術選定の裏側と実践的OSS活用〜
grandbig
2
190
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
生成AI時代のエンジニア育成 変わる時代と変わらないコト
starfish719
0
5k
Bluesky Meetup in Tokyo vol.4 - 2023to2026
shinoharata
0
190
会社紹介資料 / Sansan Company Profile
sansan33
PRO
17
410k
#jawsugyokohama 100 LT11, "My AWS Journey 2011-2026 - kwntravel"
shinichirokawano
0
270
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
200
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
260
Raft: Consensus for Rubyists
vanstee
141
7.4k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Typedesign – Prime Four
hannesfritz
42
3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.4k
Designing Experiences People Love
moore
143
24k
Discover your Explorer Soul
emna__ayadi
2
1.1k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
30 Presentation Tips
portentint
PRO
1
270
Transcript
知られざるprops命名の慣習 アクション編 2025-08-27 「実践Next.js!AIアウトプットと コンポーネント設計」 最新事情 LT
発表者紹介 uhyo 株式会社カオナビ フロントエンドエキスパート 実は業務ではNext.jsを扱っていない。 2
アクションとは React 19で登場した概念。 RSCのServer Functionsとも関係がある。 (以前Server Actionsと呼ばれてましたね) アクションはコールバック関数であり、 アクションの中で発生したステート更新は トランジションを発生させる。
3
アクションの例① formのアクション <form action={(data) => { // この関数がアクション // ↓このステート更新がトランジション扱い
setSearchKeyword(data); }}> <p><input …></p> </form> 4
アクションの例② useTransition const [isPending, startTransition] = useTransition(); <button disabled={isPending} onClick={()
=> startTransition(() => { // この関数がアクション // ↓このステート更新がトランジション扱い setState(…); }); }}> Do something fancy </button> 5
ボタンをコンポーネント化した const MyButton = ({ onClick }) => { const
[isPending, startTransition] = useTransition(); return (<button disabled={isPending} onClick={() => startTransition(() => { onClick(); }); }}> Do something fancy </button>); }; 6
ボタンをコンポーネント化した const MyButton = ({ onClick }) => { const
[isPending, startTransition] = useTransition(); return (<button disabled={isPending} onClick={() => startTransition(() => { onClick(); }); }}> Do something fancy </button>); }; 7 onClickをアクションの中で 呼び出してくれる (Suspenseとの親和性◎)
本題: propsの命名規則 const MyButton = ({ action }) => {
const [isPending, startTransition] = useTransition(); return (<button disabled={isPending} onClick={() => startTransition(() => { action(); }); }}> Do something fancy </button>); }; 8 アクションとして呼び出され るコールバックpropsには、 actionという名前を付ける
本題: propsの命名規則 propsにactionと命名するのはルールではないが、 慣習としてReactの公式ドキュメントに記載がある。 9 https://ja.react.dev/reference/react/useTr ansition#functions-called-in- starttransition-are-called-actions
action propsの注意点 const MyButton = ({ clickAction }) => {
const [isPending, startTransition] = useTransition(); return (<button disabled={isPending} onClick={() => startTransition(async() => { await clickAction(); }); }}> Do something fancy </button>); }; 10 アクションpropが同期でも非同期 でも対応できるように、 awaitするのがベストプラクティス xxxActionという命名も可 (onXXXみたいなノリで)
まとめ React 19では、onClickではなくclickActionという prop命名にすべき場合がある。(単にactionも可) むしろ、汎用コンポーネントにトランジション開始 機能を持たせて、積極的にaction propにしたい。 11