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
AgentCoreとHuman in the Loop
har1101
5
240
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
CSC307 Lecture 05
javiergs
PRO
0
500
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
Data-Centric Kaggle
isax1015
2
770
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
730
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
180
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.5k
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
140
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.3k
Featured
See All Featured
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
117
110k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
750
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
The Language of Interfaces
destraynor
162
26k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.7k
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
The Cult of Friendly URLs
andyhume
79
6.8k
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
スッキリ!
ご清聴ありがとうございました