7th Practical Class:
More Hooks, forwardRef, memo
Some More Hooks
useMemo
,useCallback
- Custom Hooks
useRef
(focus)
useMemo
, useCallback
Whithout Memoization:
With Memoization:
React.memo
- Use React.memo() wisely
- ๐งโ use
React.memo
only when something becomes slow - ๐งโ overuse of
React.memo
will make your app much slower! - remember: Premature optimization is the root of all evil
- same is for
useMemo
anduseCallback
- use it only when needed
- same is for
- ๐งโ use
Custom Hooks
- see Building Your Own Hooks
- use
use*
prefix!
useRef
React.forwardRef
React.forwardRef
documentation- allows you to use
ref
in custom components
Enable ref
for custom component: