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
31
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
54
Other Decks in Programming
See All in Programming
data-viz-talk-cz-2025
lcolladotor
0
100
GC25 Recap: The Code You Reviewed is Not the Code You Built / #newt_gophercon_tour
mazrean
0
140
釣り地図SNSにおける有料機能の実装
nokonoko1203
0
200
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
640
alien-signals と自作 OSS で実現する フレームワーク非依存な ロジック共通化の探求 / Exploring Framework-Agnostic Logic Sharing with alien-signals and Custom OSS
aoseyuu
3
4.7k
AI時代に必須!状況言語化スキル / ai-context-verbalization
minodriven
2
250
三者三様 宣言的UI
kkagurazaka
0
320
CSC509 Lecture 08
javiergs
PRO
0
270
オープンソースソフトウェアへの解像度🔬
utam0k
18
3.2k
When Dependencies Fail: Building Antifragile Applications in a Fragile World
selcukusta
0
120
Software Architecture
hschwentner
6
2.4k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
640
Featured
See All Featured
Producing Creativity
orderedlist
PRO
348
40k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
191
56k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
How to train your dragon (web standard)
notwaldorf
97
6.3k
We Have a Design System, Now What?
morganepeng
53
7.9k
The Cult of Friendly URLs
andyhume
79
6.6k
Making Projects Easy
brettharned
120
6.4k
Side Projects
sachag
455
43k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Designing for humans not robots
tammielis
254
26k
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)