Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
840
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
2
690
TypeScript 6.0で非推奨化されるオプションたち
uhyo
17
6.4k
Claude Code 10連ガチャ
uhyo
5
970
AI時代、“平均値”ではいられない
uhyo
8
3.4k
意外と難しいGraphQLのスカラー型
uhyo
5
950
RSCの時代にReactとフレームワークの境界を探る
uhyo
13
4.6k
libsyncrpcってなに?
uhyo
0
750
Next.jsと状態管理のプラクティス
uhyo
7
19k
Other Decks in Technology
See All in Technology
アプリにAIを正しく組み込むための アーキテクチャ── 国産LLMの現実と実践
kohju
0
230
AWSインフルエンサーへの道 / load of AWS Influencer
whisaiyo
0
220
特別捜査官等研修会
nomizone
0
580
【開発を止めるな】機能追加と並行して進めるアーキテクチャ改善/Keep Shipping: Architecture Improvements Without Pausing Dev
bitkey
PRO
1
130
Identity Management for Agentic AI 解説
fujie
0
470
2025-12-27 Claude CodeでPRレビュー対応を効率化する@機械学習社会実装勉強会第54回
nakamasato
4
1.1k
業務の煩悩を祓うAI活用術108選 / AI 108 Usages
smartbank
9
12k
AI駆動開発の実践とその未来
eltociear
2
500
なぜ あなたはそんなに re:Invent に行くのか?
miu_crescent
PRO
0
210
NIKKEI Tech Talk #41: セキュア・バイ・デザインからクラウド管理を考える
sekido
PRO
0
210
AWSに革命を起こすかもしれない新サービス・アップデートについてのお話
yama3133
0
510
Agent Skillsがハーネスの垣根を超える日
gotalab555
6
4.4k
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
0
30k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
410
AI: The stuff that nobody shows you
jnunemaker
PRO
1
24
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
110
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
57
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
73
Mind Mapping
helmedeiros
PRO
0
39
More Than Pixels: Becoming A User Experience Designer
marktimemedia
2
260
Speed Design
sergeychernyshev
33
1.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Six Lessons from altMBA
skipperchong
29
4.1k
WENDY [Excerpt]
tessaabrams
8
35k
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