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.6k
12
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
知られざるprops命名の慣習 アクション編
2025-08-27 Findy TECH BATON「実践Next.js!AIアウトプットとコンポーネント設計」 最新事情 LT
uhyo
August 27, 2025
More Decks by uhyo
See All by uhyo
React、まだ楽しくて草
uhyo
7
4.2k
TypeScript 7.0の現在地と備え方
uhyo
6
3.3k
React 19時代のコンポーネント設計ベストプラクティス
uhyo
20
9.7k
型定義でAIと会話する:型を通じてAIに意図を伝えるテクニック
uhyo
1
84
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
3
1.1k
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
3
900
TypeScript 6.0で非推奨化されるオプションたち
uhyo
18
8.3k
Claude Code 10連ガチャ
uhyo
4
1.1k
AI時代、“平均値”ではいられない
uhyo
8
11k
Other Decks in Technology
See All in Technology
AI Adaptable なテストを整える工夫 / Ways to Make Your Tests AI-Adaptable
bitkey
PRO
3
230
サイバーセキュリティ概論 / Introduction to Cybersecurity
ks91
PRO
0
170
個人の発見を、組織の知恵に 〜生成AI活用を"探索"から"組織の仕組み"へ〜
kintotechdev
3
1.1k
AI活用を推進するために ファインディが下した、一つの小さな決断
starfish719
0
280
ブロックチェーン / Blockchain
ks91
PRO
0
110
AIの性能が向上しても未解決な組織の重大問題は何か?/An Unsolved Organizational Problem in the Age of AI
moriyuya
3
500
EventBridge Connection
_kensh
5
670
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development with AI-DLC
yoshidashingo
0
160
Rancherの紹介&Update情報(RancherJP Online Meetup #09)
yoshiyuki_kono
0
140
PHP と TypeScript の型システム比較:AI 時代の「型」は誰のためにあるのか? #frontend_phpcon_do / frontend_phpcon_do_2026
shogogg
1
270
スキルと MCP ツール、責務をどう分けるか? AI が迷わないインターフェース設計の戦略
cdataj
1
510
Agentic Defenseとともにセキュリティエンジニアが輝き続けるには / How Security Engineers Can Keep Excelling with Agentic Defense
yuj1osm
0
130
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
480
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
Being A Developer After 40
akosma
91
590k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
140
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
240
Measuring & Analyzing Core Web Vitals
bluesmoon
9
860
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
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