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
How Hooks Work under the Hood?
Search
miycctwn
August 25, 2020
Programming
0
30
How Hooks Work under the Hood?
公司內部 React workshop 分享
miycctwn
August 25, 2020
Tweet
Share
More Decks by miycctwn
See All by miycctwn
自己的工具自己造,咱們來造 React Hooks!
mindytai
0
53
Other Decks in Programming
See All in Programming
Introducing ReActionView: A new ActionView-compatible ERB Engine @ Rails World 2025, Amsterdam
marcoroth
0
710
Swift Updates - Learn Languages 2025
koher
2
520
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
230
スケールする組織の実現に向けた インナーソース育成術 - ISGT2025
teamlab
PRO
2
170
為你自己學 Python - 冷知識篇
eddie
1
350
Tool Catalog Agent for Bedrock AgentCore Gateway
licux
7
2.6k
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
300
個人開発で徳島大学生60%以上の心を掴んだアプリ、そして手放した話
akidon0000
1
150
アセットのコンパイルについて
ojun9
0
130
Compose Multiplatform × AI で作る、次世代アプリ開発支援ツールの設計と実装
thagikura
0
170
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
870
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
130
Featured
See All Featured
Gamification - CAS2011
davidbonilla
81
5.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
GitHub's CSS Performance
jonrohan
1032
460k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Typedesign – Prime Four
hannesfritz
42
2.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
810
How GitHub (no longer) Works
holman
315
140k
BBQ
matthewcrist
89
9.8k
Transcript
How Hooks Work under the Hood?
01 JS Closure
Scope Chain 切分變數最有效範圍是 function
試看以下程式碼
None
內層的 function 可以讀取外層宣告的變數 但外層的 outer function 存取不到內層變數 若是自己層級找不到會一層一層往外找 直到 Global
None
function 是被定義的當下決定的 並不是被呼叫才被定義
Closure 當 inner function 被回傳後 可以取得內部函式環境裡的變數值 記住了當時的環境 這就是閉包!
0 2 useState
None
如果要更貼近真實的 React Hook API state 必須要為變數
None
Module Pattern Javascript Design Pattern
None
Ref 1. Deep dive: How do React hooks really work?
2. 0 陷阱!0 誤解!8 天重新認識 JavaScript!- 許國政 (Kuro)