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
Introducing React Hooks
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Rizal Ibnu
May 04, 2019
Programming
310
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introducing React Hooks
Introducing React Hooks
Rizal Ibnu
May 04, 2019
More Decks by Rizal Ibnu
See All by Rizal Ibnu
Bermain dengan React 360
rizalibnu
0
240
Getting Started Remote Working - Kerja Sarungan, Potensi Gaji Karungan
rizalibnu
0
250
Reusable React Component in Kumparan
rizalibnu
0
300
Other Decks in Programming
See All in Programming
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
420
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
My Marp Sample
sinoue0108
0
130
MySQLとPostgreSQLって何が違うの?
akagami
0
150
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
560
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
200
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
400
バグを直したら useEffect が消えた
colorful12
3
760
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
390
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.1k
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
270
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
520
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
630
Evolving SEO for Evolving Search Engines
ryanjones
0
270
Abbi's Birthday
coloredviolet
3
9.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
We Are The Robots
honzajavorek
0
310
Bash Introduction
62gerente
615
220k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
260
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
220
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
500
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
57k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
500
Transcript
Introducing React Hooks Rizal Ibnu Software Engineer @kumparan
What, Why & How ?
What, Why & How ?
What are Hooks?
What are Hooks? ?
What are Hooks? ?
What are Hooks? Hooks are a new addition in React
16.8. They let you use state and other React features (such as lifecycle) without writing a class.
What, Why & How ?
Why do we need Hooks?
Why do we use React? • Reusable components • Sensible
data flow • It’s fun to code!
Problems with writing React Class Component? • How to reuse
stateful logic • Huge component • Class is confusing (for both humans and machines)
React Class Component
Might have to reuse this in some other components React
Class Component
React Class Component Split all over the place
How we deal with them? • Mixins (The old way)
• Higher-Order Components a.k.a HOC • Render Props
HOC
HOC
HOC
HOC
HOC Maybe?
HOC
HOC
HOC
HOC
HOC
HOC
HOC WRAPPER HELL
HOC Render Props Hooks Reuse Stateful Logic Explicit Props Composability
No “Wrapper Hell”
Render Props
Render Props
Render Props
Render Props
Render Props
Render Props
Render Props WRAPPER HELL
HOC Render Props Hooks Reuse Stateful Logic Explicit Props Composability
No “Wrapper Hell”
HOC Render Props Hooks Reuse Stateful Logic Explicit Props Composability
No “Wrapper Hell” SPOILER ALERT
What, Why & How ?
HOC Render Props Hooks
Let’s code
HOC Render Props Hooks
Hooks
Hooks
HOC Render Props Hooks Reuse Stateful Logic Explicit Props Composability
No “Wrapper Hell”
But nothing is perfect
Rule of Hooks 1. Only Call Hooks at the Top
Level Don’t call Hooks inside loops, conditions, or nested functions. 2. Only Call Hooks from React Functions Not from regular JS functions or inside class components, but you can call them from custom hooks.
About Hooks • No breaking change • Class still works
• It will cover all use cases for classes! (except getSnapshotBeforeUpdate and componentDidCatch , but they plan to add them soon)
Hooks API Basic Hooks Additional Hooks useState useEffect useContext useReducer
useCallback useMemo useRef useImperativeHandle useLayoutEffect useDebugValue https://reactjs.org/docs/hooks-reference.html
How to try Hooks yarn add react@^16.8.0 yarn add react-dom@^16.8.0
(web) yarn add react-native@^0.59.0 (react native) Recommended yarn add eslint-plugin-react-hooks --dev Code Example https://github.com/rizalibnu/ReactHooksExample (web) https://github.com/rizalibnu/ReactNativeHooksExample (react native)
Reference • https://reactjs.org/docs/hooks-intro.html • https://facebook.github.io/react-native/blog/2019/03/12/releasing-re act-native-059 • https://www.slideshare.net/AikdanaiSidhikosol/react-hooks-101
END GAME