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.memoonly when something becomes slow - ๐งโ overuse of
React.memowill make your app much slower! - remember: Premature optimization is the root of all evil
- same is for
useMemoanduseCallback- use it only when needed
- same is for
- ๐งโ use
Custom Hooks
- see Building Your Own Hooks
- use
use*prefix!
useRef
React.forwardRef
React.forwardRefdocumentation- allows you to use
refin custom components
Enable ref for custom component: