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
作ろう、Custom Hooks
Search
surumebeer
October 02, 2019
Programming
1
330
作ろう、Custom Hooks
surumebeer
October 02, 2019
Tweet
Share
More Decks by surumebeer
See All by surumebeer
about ES and TC39
surumebeer
0
270
Other Decks in Programming
See All in Programming
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
730
CSC307 Lecture 03
javiergs
PRO
1
490
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
今から始めるClaude Code超入門
448jp
8
8.8k
CSC307 Lecture 06
javiergs
PRO
0
690
Patterns of Patterns
denyspoltorak
0
1.4k
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
720
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.3k
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
300
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
620
Raku Raku Notion 20260128
hareyakayuruyaka
0
180
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
2
250
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
120
Mobile First: as difficult as doing things right
swwweet
225
10k
Accessibility Awareness
sabderemane
0
51
ラッコキーワード サービス紹介資料
rakko
1
2.3M
The Mindset for Success: Future Career Progression
greggifford
PRO
0
240
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Optimizing for Happiness
mojombo
379
71k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
750
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
スッキリ!
ご清聴ありがとうございました