js401-reading
Custom Hooks
What?
extract duplicated logic from components
share funtionality (not state)
utilized
useEffect
lifecycle
Common uses:
handle forms
pre-fetch api data
connect to services (socket.io, Q, etc.)
The How…
hooks are exported as a function
hooks return data or functions
imported to components
component can then re-use functionality or data/state
hooks do NOT render
Resources
Authoring
custom hooks - all you need to know
prefixed with
use
hooks are just imported functions, which can in turn access other functions
async hooks
useReducer hook
react custom hooks
Hooks Lists/Collections
use hooks
hooks list
10 essential react hooks