4IT580: Docs
4IT580 WebGithub

11th Practical Class:
More hooks, memo, forwardRef

Problem

Your app re-renders often with the same props and its re-rendering process is expensive, which makes the UI unresponsive.

Solutions

One solution is memoization - caching output values calculated with the same inputs.

useMemo, useCallback

Without Memoization:

With Memoization:

React.memo

React Developer Tools

Don't try to memoize everything

useRef

React.forwardRef

Enable ref for custom component: