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
320
作ろう、Custom Hooks
surumebeer
October 02, 2019
Tweet
Share
More Decks by surumebeer
See All by surumebeer
about ES and TC39
surumebeer
0
260
Other Decks in Programming
See All in Programming
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
2
610
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
280
git worktree × Claude Code × MCP ~生成AI時代の並列開発フロー~
hisuzuya
1
520
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
0
330
ふつうの技術スタックでアート作品を作ってみる
akira888
0
320
Modern Angular with Signals and Signal Store:New Rules for Your Architecture @enterJS Advanced Angular Day 2025
manfredsteyer
PRO
0
170
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
260
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.5k
Deep Dive into ~/.claude/projects
hiragram
11
2.3k
童醫院敏捷轉型的實踐經驗
cclai999
0
210
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
530
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
670
Featured
See All Featured
Balancing Empowerment & Direction
lara
1
400
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.8k
How STYLIGHT went responsive
nonsquared
100
5.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
How to Ace a Technical Interview
jacobian
277
23k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
KATA
mclloyd
30
14k
Building Adaptive Systems
keathley
43
2.6k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
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
スッキリ!
ご清聴ありがとうございました