-
Book Overview & Buying
-
Table Of Contents
Designing React Hooks the Right Way
By :
In the previous chapter, we learned how useMemo is designed and how to use useMemo to conditionally reuse the last value. In this chapter, we will talk about how to propagate changes to cover an area update. We will introduce what an area update is and how React context is used to share a value within that area. Then, we will walk through the data structure and source code behind useContext to consume the shared value. And finally, we'll provide two practical examples of applying contexts to the theme and the table. The chapter also includes two bonus topics in the Appendix section: Propagating a context and Context scope and value.
We will cover the following topics in this chapter:
useContext designuseContext useContext examples
Change the font size
Change margin width
Change background colour