-
Book Overview & Buying
-
Table Of Contents
React Application Architecture for Production - Second Edition
By :
Since React is all about components, we need to have the right approach when it comes to building and composing them together for optimal performance. The way we structure our components directly impacts how often they re-render and how much work React must do.
Here are some important techniques for optimizing components for best performance:
Let's take a look at a practical example of how to apply these techniques.
State colocation means keeping state as close as possible to where it's used. If only one component needs a piece of state, that state should live in that component, not in a parent. This is one of the most impactful performance optimizations because it directly controls which components re-render.
Consider a dashboard that has a user profile section and an ideas list. Here's a common mistake where all state lives in one component:
function Dashboard...