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
900
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
2
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
AI Agent Agentic Workflow の可観測性 / Observability of AI Agent Agentic Workflow
yuzujoe
5
2.2k
CodeRabbit CLI + Claude Codeの連携について
oikon48
0
520
Behind the Stream - How AbemaTV Engineers Build Video Apps at Scale
ygoto3
0
120
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
340
これまでのネットワーク運用を変えるかもしれないアプデをおさらい
hatahata021
4
230
SOC2は、取った瞬間よりその後が面白い
3flower
0
140
ドメイン駆動セキュリティへの道しるべ
pandayumi
0
160
手軽に作れる電卓を作って イベントソーシングに親しもう CQRS+ESカンファレンス2026
akinoriakatsuka
0
500
kintone開発のプラットフォームエンジニアの紹介
cybozuinsideout
PRO
0
550
純粋なイミュータブルモデルを設計してからイベントソーシングと組み合わせるDeciderの実践方法の紹介 /Introducing Decider Pattern with Event Sourcing
tomohisa
1
1.2k
旬のブリと旬の技術で楽しむ AI エージェント設計開発レシピ
chack411
1
300
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
3
420
Featured
See All Featured
ラッコキーワード サービス紹介資料
rakko
1
2.1M
Believing is Seeing
oripsolob
1
33
A better future with KSS
kneath
240
18k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
290
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
89
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Documentation Writing (for coders)
carmenintech
77
5.2k
Are puppies a ranking factor?
jonoalderson
1
2.6k
Site-Speed That Sticks
csswizardry
13
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