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.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
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
2
910
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
3
740
TypeScript 6.0で非推奨化されるオプションたち
uhyo
17
6.7k
Claude Code 10連ガチャ
uhyo
5
980
AI時代、“平均値”ではいられない
uhyo
8
3.6k
意外と難しいGraphQLのスカラー型
uhyo
5
990
RSCの時代にReactとフレームワークの境界を探る
uhyo
13
4.7k
libsyncrpcってなに?
uhyo
0
770
Next.jsと状態管理のプラクティス
uhyo
7
22k
Other Decks in Technology
See All in Technology
AIAgentを駆使してSREが貢献する開発体験の向上
yoshiiryo1
3
1k
会社紹介資料 / Sansan Company Profile
sansan33
PRO
13
400k
ビジュアルプログラミングIoTLT vol.22
1ftseabass
PRO
0
110
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
950
AI Agent Standards and Protocols: a Walkthrough of MCP, A2A, and more...
glaforge
1
480
2026/01/16_実体験から学ぶ 2025年の失敗と対策_Progate Bar
teba_eleven
1
210
VRTと真面目に向き合う
hiragram
1
370
Eight Engineering Unit 紹介資料
sansan33
PRO
0
6.4k
20260120 Amazon VPC のパブリックサブネットを無くしたい!
masaruogura
2
150
持続可能な開発のためのミニマリズム
sansantech
PRO
3
470
kintone開発のプラットフォームエンジニアの紹介
cybozuinsideout
PRO
0
560
Kusakabe_面白いダッシュボードの表現方法
ykka
0
370
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
400
AI Search: Where Are We & What Can We Do About It?
aleyda
0
6.9k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
ラッコキーワード サービス紹介資料
rakko
1
2.1M
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
140
GitHub's CSS Performance
jonrohan
1032
470k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
430
Building the Perfect Custom Keyboard
takai
2
670
The SEO identity crisis: Don't let AI make you average
varn
0
55
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