Knowledgebase

Avoiding State Management Mistakes Print

  • frontenddevelopment, frontend, woocommerce, caching, guide, howto, solution, zillionkinghost
  • 0

Common errors.

PUTTING EVERYTHING IN A GLOBAL STORE

Which makes the application difficult to reason about, and re-renders broadly.

DUPLICATING THE SAME DATA IN SEVERAL PLACES

The copies diverge, and nobody knows which is correct.

STORING DERIVED VALUES

Compute them instead.

TREATING SERVER DATA AS OWNED STATE

It is a cache, and needs invalidation.

NOT PUTTING FILTERS AND SEARCH IN THE ADDRESS

Users cannot share or return to what they were looking at.

SELECTING TOO BROADLY

Components re-rendering when unrelated state changes.

USING CONTEXT FOR FREQUENTLY CHANGING VALUES

Everything consuming it re-renders on every change.

SHARED STORES ON THE SERVER

Leaking data between users, which is a serious fault.

NO CONVENTION FOR WHERE STATE LIVES

Producing state scattered unpredictably.

WHAT PREVENTS MOST OF THESE

One source of truth for each piece of data, and keeping state as local as possible.

WHAT TO ASK OF ANY STATE

Who owns this, and who needs it?


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot