-
Book Overview & Buying
-
Table Of Contents
Designing React Hooks the Right Way
By :
In the previous chapter, we learned how the useEffect hook is designed and how to use it to manage a side effect in React. In this chapter, we will change to an optimization topic for reusing the last assignment. We will first introduce how we can run into performance degradation in a typical web application. Then, we will walk through the design and source code behind useMemo and describe various ways of reusing a value conditionally. We'll then apply the optimization technique to two common cases: clicking to search and debouncing the search. At the end, the chapter also includes two bonus topics in the Appendix section, Not a Classical Memorization and Skipping a Child Update.
We will cover the following main topics in this chapter:
useMemo designuseMemo useMemo examples
Change the font size
Change margin width
Change background colour