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.2k
知られざる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
Claude Code 10連ガチャ
uhyo
3
680
AI時代、“平均値”ではいられない
uhyo
8
3k
意外と難しいGraphQLのスカラー型
uhyo
5
870
RSCの時代にReactとフレームワークの境界を探る
uhyo
13
4.4k
libsyncrpcってなに?
uhyo
0
720
Next.jsと状態管理のプラクティス
uhyo
7
16k
10ヶ月かけてstyled-components v4からv5にアップデートした話
uhyo
5
680
更新系と状態
uhyo
9
4k
React 19アップデートのために必要なこと
uhyo
8
2.9k
Other Decks in Technology
See All in Technology
レビュー負債を解消する ― CodeRabbitが支えるAI駆動開発
moongift
PRO
0
360
探求の技術
azukiazusa1
7
2.2k
仕様駆動 x Codex で 超効率開発
ismk
2
1.5k
プログラミング言語を書く前に日本語を書く── AI 時代に求められる「言葉で考える」力/登壇資料(井田 献一朗)
hacobu
PRO
0
160
Kubernetesと共にふりかえる! エンタープライズシステムのインフラ設計・テストの進め方大全
daitak
0
140
ある編集者のこれまでとこれから —— 開発者コミュニティと歩んだ四半世紀
inao
4
3.1k
What's the recommended Flutter architecture
aakira
3
1.6k
Dart and Flutter MCP serverで実現する AI駆動E2Eテスト整備と自動操作
yukisakai1225
0
510
Rubyist入門: The Way to The Timeless Way of Programming
snoozer05
PRO
6
450
AIを前提に、業務を”再構築”せよ IVRyの9ヶ月にわたる挑戦と未来の働き方 (BTCONJP2025)
yueda256
1
700
これからアウトプットする人たちへ - アウトプットを支える技術 / that support output
soudai
PRO
18
5.5k
ソフトウェア開発現代史: 55%が変化に備えていない現実 ─ AI支援型開発時代のReboot Japan #agilejapan
takabow
6
4k
Featured
See All Featured
Designing for Performance
lara
610
69k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Faster Mobile Websites
deanohume
310
31k
Fireside Chat
paigeccino
41
3.7k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Mobile First: as difficult as doing things right
swwweet
225
10k
Into the Great Unknown - MozCon
thekraken
40
2.2k
YesSQL, Process and Tooling at Scale
rocio
174
15k
We Have a Design System, Now What?
morganepeng
54
7.9k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
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