๐ฅ๐ฒ๐ฎ๐ฐ๐ ๐๐ผ๐ผ๐ธ๐ ๐ง๐ถ๐ฝ
React creates new functions on every render. Child components see this as a change. They re-render even if the data stays the same. This slows your app.
Use useCallback. It stores your function. It stops extra renders. Your app runs faster.
Follow these steps:
- Wrap your function in useCallback.
- Add dependencies in the array.
- Use React.memo on child components.
Source: https://dev.to/vishwajeet81/tip-of-the-day-on-react-hooks-2ceb