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
Baseline対応のDOMの型定義を作った
uhyo
3
720
AIのReact習熟度を測る
uhyo
2
810
React、まだ楽しくて草
uhyo
7
4.6k
TypeScript 7.0の現在地と備え方
uhyo
6
3.5k
React 19時代のコンポーネント設計ベストプラクティス
uhyo
20
10k
型定義でAIと会話する:型を通じてAIに意図を伝えるテクニック
uhyo
1
95
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
3
1.1k
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
3
920
TypeScript 6.0で非推奨化されるオプションたち
uhyo
18
8.4k
Other Decks in Technology
See All in Technology
CSに"SLO"は要らない、経営層に"99.9%"は伝わらない - SREを全社に"翻訳"する3原則
cscengineer
PRO
1
3.8k
DMM.com 購入改善推進チーム におけるCodeRabbitを用いた レビューフロー改善の一例
ysknsid25
2
550
キャリアの中で本を作る / Making a Book During Your Career
ak1210
0
120
記録をかんたんに、提案をパーソナルに ── AIであすけんが目指すもの
oprstchn
0
170
美しいコードを書くためにF#を学んでみた話
yud0uhu
1
360
ローカルLLMとLINE Botの組み合わせ その3 / LINE DC Generative AI Meetup #8
you
PRO
0
130
SRE歴2ヶ月でも開発6年の知見を活かして、チームで止まっていた環境改善を前に進めた話
a_ono
1
220
知らん間に、回ってる
ming_ayami
0
340
プライバシー保護の理論と実践
lycorptech_jp
PRO
1
250
Claude Code 珍プレー好プレー
shinyasaita
0
290
知見・人・API・DB・予算 ─ ナイナイ尽くしだった人事データ整備 with dbt、5年間の学び
ken6377
1
170
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
260
Featured
See All Featured
Navigating Team Friction
lara
192
16k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
The Curious Case for Waylosing
cassininazir
1
430
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
Product Roadmaps are Hard
iamctodd
55
12k
How STYLIGHT went responsive
nonsquared
100
6.2k
Claude Code のすすめ
schroneko
67
230k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
410
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