Summary
In this chapter, we first learned about a new hook, useMemo
. We first briefly went over what can cause performance degradation in general, and then we learned about the useMemo
design and read line by line how an optimization scheme is constructed to reuse the last value without creating a new one every time. Then, we went through all scenarios of reusing a value based on a dependency array. We took useMemo
for a spin, and at the end, we saw how it's applied to two classic examples, clicking to search and debouncing the search.
In the next chapter, we will get into another hook in the React family where a state change can be dispatched to multiple locations for an are update.