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
Rizal Ibnu
May 04, 2019
Programming
280
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
220
Getting Started Remote Working - Kerja Sarungan, Potensi Gaji Karungan
rizalibnu
0
220
Reusable React Component in Kumparan
rizalibnu
0
260
Other Decks in Programming
See All in Programming
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
310
Vite+ Unified Toolchain for the Web
naokihaba
0
740
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
240
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
160
継続モナドとリアクティブプログラミング
yukikurage
3
470
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
3.8k
symfony/aiとlaravel/boost
77web
0
120
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
580
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
190
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.6k
Featured
See All Featured
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
210
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
750
Optimizing for Happiness
mojombo
378
71k
Everyday Curiosity
cassininazir
0
250
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Marketing to machines
jonoalderson
1
5.6k
Prompt Engineering for Job Search
mfonobong
0
370
A Tale of Four Properties
chriscoyier
163
24k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Music & Morning Musume
bryan
47
7.3k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
260
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
630
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