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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
uhyo
August 27, 2025
Technology
12
3.4k
知られざる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
React 19時代のコンポーネント設計ベストプラクティス
uhyo
18
7.6k
型定義でAIと会話する:型を通じてAIに意図を伝えるテクニック
uhyo
1
33
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
3
1k
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
3
800
TypeScript 6.0で非推奨化されるオプションたち
uhyo
17
7.2k
Claude Code 10連ガチャ
uhyo
5
1k
AI時代、“平均値”ではいられない
uhyo
8
3.9k
意外と難しいGraphQLのスカラー型
uhyo
5
1k
RSCの時代にReactとフレームワークの境界を探る
uhyo
13
4.9k
Other Decks in Technology
See All in Technology
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
18k
大規模サービスにおける レガシーコードからReactへの移行
magicpod
1
130
トップマネジメントとコンピテンシーから考えるエンジニアリングマネジメント
zigorou
3
540
Oracle Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
1.6k
20260305_【白金鉱業】分析者が地理情報を武器にするための軽量なアドホック分析環境
yucho147
1
170
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
44k
kintone開発のプラットフォームエンジニアの紹介
cybozuinsideout
PRO
0
820
EMからICへ、二周目人材としてAI全振りのプロダクト開発で見つけた武器
yug1224
4
400
vLLM Community Meetup Tokyo #3 オープニングトーク
jpishikawa
0
110
GitLab Duo Agent Platform + Local LLMサービングで幸せになりたい
jyoshise
0
110
Lookerの最新バージョンv26.2がやばい話
waiwai2111
1
160
越境する組織づくり ─ 多様性を前提にしたチームビルディングとリードの実践知
kido_engineer
1
110
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
300
We Are The Robots
honzajavorek
0
190
GitHub's CSS Performance
jonrohan
1032
470k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
230
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
470
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
380
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
170
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
79
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
130
Context Engineering - Making Every Token Count
addyosmani
9
740
Abbi's Birthday
coloredviolet
2
5.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
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