Looking at React's useMemo documentation. They say to use it when you need to compute an expensive calculation.
This optimization helps to avoid expensive calculations on every render.
I looked at the memoized link they provide and what I understood is that you can think of it like an cache.
I'm not an expert at computer science, but I know that memoization is a good optimization for calculating fibonacci
I'm still trying to understand better why and how to use useMemo, but a few things are still unclear to me.
- What is considered
expensive calculations? - Can someone give real
reactexamples? - In what cases
useMemois good for performance optimization?