Why I am
hooked on the
future of React
@mauricedb
© ABL - The Problem Solver 1
 Maurice de Beijer
 The Problem Solver
 Microsoft MVP
 Freelance developer/instructor
 Twitter: @mauricedb
 Web: http://www.TheProblemSolver.nl
 E-mail: maurice.de.beijer@gmail.com
2ABL - The Problem Solver
The React
Newsletter
© ABL - The Problem Solver 4
http://bit.ly/ReactNewsletter
History
of
Components
© ABL - The Problem Solver 5
Original
Component
API
© ABL - The Problem Solver 6
Class
Components
© ABL - The Problem Solver 7
State
&
Lifecycle
© ABL - The Problem Solver 8
The problem
with classes
© ABL - The Problem Solver 9
this
© ABL - The Problem Solver 10
Fat arrow for
some functions
© ABL - The Problem Solver 11
Single
responsibility
in multiple
functions
© ABL - The Problem Solver 12
Functional
Components
© ABL - The Problem Solver 13
The
Problem
© ABL - The Problem Solver 14
And
© ABL - The Problem Solver 15
If your only
tool …
© ABL - The Problem Solver 16
Deeply
Nested
Components
© ABL - The Problem Solver 17
Many are
wrappers to
add props
© ABL - The Problem Solver 18
Render
Props
© ABL - The Problem Solver 19
But…
© ABL - The Problem Solver 20
Introducing
Hooks
© ABL - The Problem Solver 21
Open
Mind
© ABL - The Problem Solver 22
State
© ABL - The Problem Solver 23
useState()
© ABL - The Problem Solver 24
Just
State
© ABL - The Problem Solver 25
Side Effects
© ABL - The Problem Solver 26
useEffect()
© ABL - The Problem Solver 27
Context
© ABL - The Problem Solver 28
Render
Props
© ABL - The Problem Solver 29
useContext()
© ABL - The Problem Solver 30
All hooks
 Basic hooks
 useState()
 useEffect()
 useContext()
 Additional Hooks
 useReducer()
 useLayoutEffect()
 useRef()
 useCallback()
 useMemo()
 useImperativeHandle()
 Custom hooks
 useDebugValue()
 Your custom hooks
© ABL - The Problem Solver 31
Custom
Hooks
© ABL - The Problem Solver 32
Custom
Hooks
© ABL - The Problem Solver 33
Using
The
Hook
© ABL - The Problem Solver 34
Rules
of
Hooks
© ABL - The Problem Solver 35
Rules
of
Hooks
© ABL - The Problem Solver 36
 Hooks can only be used in functional components
 Or in other hooks
 Not in class based components
 Hooks must always be created in the same order
 Must be outside loops, conditions or nested functions
 Hooks names must be prefixed with `use`
 There is an ESLint plugin to enforce these rules
Hooks are
optional
© ABL - The Problem Solver 37
Classes will
keep on
working
© ABL - The Problem Solver 38
Maurice de Beijer
@mauricedb
© ABL - The Problem Solver 39

Why I am hooked on the future of React

Editor's Notes

  • #24 https://pixabay.com/nl/photos/mount-rushmore-beeldhouwkunst-3608620/
  • #27 https://pixabay.com/nl/photos/antelope-canyon-zandsteen-canyon-1128815/
  • #33 https://unsplash.com/photos/CrhsIRY3JWY
  • #36 https://pixabay.com/nl/illustrations/regels-boord-cirkel-lettertype-1752415/