-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn React with TypeScript
By :

We started this chapter by looking at different categories of state. We learned how to manage state robustly for each category. We spent most of the chapter focusing on the trickiest category of state, shared state. We built a small one-page app that contained components that needed to share state.
We started our shared state exploration by using the prop drilling approach. This is the simplest approach and ideal for a few adjacent components. However, it’s cumbersome for lots of components – particularly if they are far apart in the component tree.
We moved on to learn about React context and refactored the app to use it. We learned that it’s more convenient than prop drilling for sharing state between many components. However, it can cause performance issues because many components often re-render when state changes.
Next, we learned about Zustand, which is similar to React context. A difference is that no provider component is required, making...