Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
知られざるprops命名の慣習 アクション編
Search
uhyo
August 27, 2025
Technology
3.8k
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
Transcript
11 slides
知られざる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
More Decks by uhyo
See All by uhyo
Content Mapper APIの応用例~CSS Modules、言語ファイル~
uhyo
2
670
Reactの設計論
uhyo
26
18k
型があると何が嬉しいか
uhyo
3
180
Baseline対応のDOMの型定義を作った
uhyo
3
1.1k
AIのReact習熟度を測る
uhyo
2
1.1k
React、まだ楽しくて草
uhyo
7
5.3k
TypeScript 7.0の現在地と備え方
uhyo
6
4k
React 19時代のコンポーネント設計ベストプラクティス
uhyo
20
11k
型定義でAIと会話する:型を通じてAIに意図を伝えるテクニック
uhyo
1
140
Other Decks in Technology
See All in Technology
「個社」ではなく「業界」の課題を解く AI 対話開発 ー 価値を広げる設計と、価値を守るエンジニアリング ー
ivry_presentationmaterials
3
790
ノードが消える前提で設計する!Karpenterで金融システムを止めないためのノウハウ大全
daitak
1
160
こんなに変わった! AWSネットワークの常識
shotashiratori
16
11k
20261113_JAWS_Osaka
takuyay0ne
1
600
_マネジメントする人される人ナイト_2026__良いチームを作っていきたい_お気持ち_.pdf
xkxaxkx
0
830
クラウドでも使えるNetApp -現場目線での設計とクラウドバックアップの活用
ryutakondo
1
190
現地速報! Microsoft Ignite アップデートレポート
kasada
0
350
メール到達性を支える、リンク先URLのドメイン評価の扱い方
wind111
0
180
お風呂場をサーバルームにしよう
yusuke427
0
380
Re:ゼロから始めるシェアハウスのペットな鯖
silmin_
0
260
AIネイティブ組織の作り方。1人のPOとAIから始める、自社での実験
ama_ch
2
1.2k
業務の傍らで進める改善ループエンジニアリング
bengo4com
1
220
Featured
See All Featured
Designing for Performance
lara
612
70k
ラッコキーワード サービス紹介資料
rakko
5
6M
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
540
We Are The Robots
honzajavorek
0
460
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
The agentic SEO stack - context over prompts
schlessera
0
1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
The Language of Interfaces
destraynor
162
27k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k