what is usememo react ?
· useMemo is a React Hook that allows you to optimize performance
by memoizing the result of a computation.
· It helps to avoid expensive calculations on every render by caching
the result and only recalculating it when its dependencies change.
· This can be particularly useful in scenarios where you have complex
calculations or when rendering large lists of data.
When to Use useMemo
· When you have expensive calculations that you want to avoid running on every render.
· When you want to prevent unnecessary re-renders of child components that rely on the
memoized value.
· When you want to optimize performance in a component that renders frequently.