All guidesFrontend

Where should React state live?

State belongs close to the code that owns it. Move it upward only when multiple components need to coordinate.

Keep local decisions local

A dropdown's open state can stay in the dropdown. Form values can live in the form until another part of the page needs them. Avoid a global store for every interaction.

Lift shared state

If a filter and a list use the same selection, store it in their nearest shared parent and pass values and callbacks through props.

Avoid duplicated values

Derive filtered results and totals from the underlying records. Storing both the input and its calculated result creates two places that can disagree.

Explore a learning path