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
作ろう、Custom Hooks
Search
surumebeer
October 02, 2019
Programming
340
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
作ろう、Custom Hooks
surumebeer
October 02, 2019
More Decks by surumebeer
See All by surumebeer
about ES and TC39
surumebeer
0
280
Other Decks in Programming
See All in Programming
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
280
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
170
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
1
410
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
520
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
650
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
920
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.5k
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5k
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
21
21k
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.6k
R8 の設定見直しでアプリサイズ削減
andpad
0
190
golang-bob.pdf
iwatsukayura
0
110
Featured
See All Featured
Ethics towards AI in product and experience design
skipperchong
2
420
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
The SEO identity crisis: Don't let AI make you average
varn
0
580
30 Presentation Tips
portentint
PRO
1
420
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Design in an AI World
tapps
1
350
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
790
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
New Earth Scene 8
popppiees
4
2.7k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Transcript
作ろう、Custom Hooks 表参道Web勉強会 『Vue.js/PWA/JavaScript…新&定番なんでもあり』 Vol8 @sururmebeer
Shuji Nishino @surumebeer 株式会社 でフロントエンドエンジニアしてます
今日話すこと…
React Hooks
React Hooksとは? • React 16.8から追加されたAPI • 関数型コンポーネントでのみ利用可能 • 関数型コンポーネント自体が状態を持てるようになった •
関数型コンポーネント内で副作用の実行も可能
None
state state更新用の関数 useStateの宣言 stateの初期値
None
useEffectの宣言 副作用 副作用が依存 している関数
stateの操作をCustom Hooks化
None
Hooksを使ってロジック部分を関数として切り離す
Custom Hooksを作って嬉しいこと • ロジック部分を分割して管理ができる • 分割したロジックを、コンポーネントの階層構造に影響することなく共有・再利用できる • プレゼンテーションのコンポーネントは、プレゼンテーションのみに専念させられる
もうちょっと実践的に…
fetchしたjsonを表示する
None
ロジック部分 プレゼンテーション ロジックとUIが同じ関数コンポーネント内にある
Custom Hooksとして切り離す
Hooksを使ってロジック部分だけ関数として切り離す
None
スッキリ!
ご清聴ありがとうございました