Knowledgebase

Deciding What Needs State Management Print

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

Before reaching for a library.

WHAT KINDS OF STATE EXIST

Local, belonging to one component Shared, needed by several Server data, fetched and cached Address state, reflected in the URL Form state

WHY THAT DISTINCTION MATTERS

They have different requirements, and one tool rarely suits all.

WHAT TO KEEP LOCAL

Anything only one component needs.

WHAT TO LIFT

State needed by a component and its siblings, to their common ancestor.

WHAT CONTEXT OR PROVIDE FACILITIES SOLVE

Passing values deeply without threading them through every level.

WHAT THEY DO NOT SOLVE

Frequent updates, which re-render everything consuming them.

WHAT ADDRESS STATE PROVIDES

State that can be shared, bookmarked and returned to.

WHAT BELONGS THERE

Filters, search terms, pagination, selected tabs.

WHY

Because users expect to be able to share a link to what they are looking at.

WHAT MOST APPLICATIONS DISCOVER

That most of what they put in a global store was server data or address state.

WHAT TO ASK BEFORE ADDING A STATE LIBRARY

What genuinely needs to be shared, and how often it changes.


Was this answer helpful?
Back

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


Trustpilot