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
12
3.3k
知られざるprops命名の慣習 アクション編
2025-08-27 Findy TECH BATON「実践Next.js!AIアウトプットとコンポーネント設計」 最新事情 LT
uhyo
August 27, 2025
Tweet
Share
More Decks by uhyo
See All by uhyo
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
2
850
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
2
700
TypeScript 6.0で非推奨化されるオプションたち
uhyo
17
6.4k
Claude Code 10連ガチャ
uhyo
5
970
AI時代、“平均値”ではいられない
uhyo
8
3.4k
意外と難しいGraphQLのスカラー型
uhyo
5
960
RSCの時代にReactとフレームワークの境界を探る
uhyo
13
4.6k
libsyncrpcってなに?
uhyo
0
750
Next.jsと状態管理のプラクティス
uhyo
7
19k
Other Decks in Technology
See All in Technology
AIエージェント開発と活用を加速するワークフロー自動生成への挑戦
shibuiwilliam
5
870
なぜ あなたはそんなに re:Invent に行くのか?
miu_crescent
PRO
0
210
M&Aで拡大し続けるGENDAのデータ活用を促すためのDatabricks権限管理 / AEON TECH HUB #22
genda
0
260
202512_AIoT.pdf
iotcomjpadmin
0
150
フィッシュボウルのやり方 / How to do a fishbowl
pauli
2
390
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
9.9k
Amazon Quick Suite で始める手軽な AI エージェント
shimy
2
1.9k
"人"が頑張るAI駆動開発
yokomachi
1
620
AgentCore BrowserとClaude Codeスキルを活用した 『初手AI』を実現する業務自動化AIエージェント基盤
ruzia
7
1.6k
株式会社ビザスク_AI__Engineering_Summit_Tokyo_2025_登壇資料.pdf
eikohashiba
1
120
日本Rubyの会: これまでとこれから
snoozer05
PRO
6
250
モダンデータスタックの理想と現実の間で~1.3億人Vポイントデータ基盤の現在地とこれから~
taromatsui_cccmkhd
2
270
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
73
Being A Developer After 40
akosma
91
590k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
260
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
230
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
200
Joys of Absence: A Defence of Solitary Play
codingconduct
1
260
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
59
Product Roadmaps are Hard
iamctodd
PRO
55
12k
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