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
240
0
Share
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
180
Getting Started Remote Working - Kerja Sarungan, Potensi Gaji Karungan
rizalibnu
0
180
Reusable React Component in Kumparan
rizalibnu
0
220
Other Decks in Programming
See All in Programming
ファインチューニングせずメインコンペを解く方法
pokutuna
0
270
存在論的プログラミング: 時間と存在を記述する
koriym
5
830
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
150
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
1.8k
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
290
今こそ押さえておきたい アマゾンウェブサービス(AWS)の データベースの基礎 おもクラ #6版
satoshi256kbyte
1
230
Don't Prompt Harder, Structure Better
kitasuke
0
460
RSAが破られる前に知っておきたい 耐量子計算機暗号(PQC)入門 / Intro to PQC: Preparing for the Post-RSA Era
mackey0225
3
120
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
230
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
120
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
340
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
980
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
96
14k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
720
How to Talk to Developers About Accessibility
jct
2
170
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
68
38k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.4k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
290
Building a Scalable Design System with Sketch
lauravandoore
463
34k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
310
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