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.5k
知られざる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
TypeScript 7.0の現在地と備え方
uhyo
7
2.1k
React 19時代のコンポーネント設計ベストプラクティス
uhyo
19
8.4k
型定義でAIと会話する:型を通じてAIに意図を伝えるテクニック
uhyo
1
54
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
3
1k
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
3
830
TypeScript 6.0で非推奨化されるオプションたち
uhyo
18
7.5k
Claude Code 10連ガチャ
uhyo
4
1k
AI時代、“平均値”ではいられない
uhyo
8
4.1k
意外と難しいGraphQLのスカラー型
uhyo
5
1.1k
Other Decks in Technology
See All in Technology
GitHub Copilot CLI で Azure Portal to Bicep
tsubakimoto_s
0
180
Copilot 宇宙へ 〜生成AIで「専門データの壁」を壊す方法〜
nakasho
0
160
Phase06_ClaudeCode実践
overflowinc
0
1.8k
Phase03_ドキュメント管理
overflowinc
0
2.3k
FlutterでPiP再生を実装した話
s9a17
0
130
The Rise of Browser Automation: AI-Powered Web Interaction in 2026
marcthompson_seo
0
300
ADK + Gemini Enterprise で 外部 API 連携エージェント作るなら OAuth の仕組みを理解しておこう
kaz1437
0
170
脳が溶けた話 / Melted Brain
keisuke69
1
900
LINEヤフーにおけるAIOpsの現在地
lycorptech_jp
PRO
5
2.2k
データマネジメント戦略Night - 4社のリアルを語る会
ktatsuya
1
210
Phase10_組織浸透_データ活用
overflowinc
0
1.5k
Agent Skill 是什麼?對軟體產業帶來的變化
appleboy
0
220
Featured
See All Featured
Six Lessons from altMBA
skipperchong
29
4.2k
For a Future-Friendly Web
brad_frost
183
10k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
450
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The Language of Interfaces
destraynor
162
26k
Scaling GitHub
holman
464
140k
Discover your Explorer Soul
emna__ayadi
2
1.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Speed Design
sergeychernyshev
33
1.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
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