The best way to understand what memoize hooks are is to expose ourselves to the problem space which these hooks solve. Starter hooks examples don’t expose these problems. They make hooks look approachable and straightforward— which makes complete sense.
The real problem starts to unravel when you use hooks more often. Spend a few more hours if you are a hooks beginner, and you will find yourself in weird pitfalls that you would not have noticed on your first day with React.
Why Memoize Hooks
A memoize hook remembers.
That is the simplest way to think about these hooks. The actual tricky questions are:
- Why do they need to remember?
- What do they remember?
- When do they remember?
I am going to attempt to teach you memoize hooks by trying as much as I can to answer these questions.