Knowledgebase

Understanding Lighter State Libraries Print

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

Simpler alternatives.

WHAT THEY PROVIDE

Shared state without the ceremony of a full pattern.

WHAT THAT LOOKS LIKE

Creating a store, and using it in any component.

WHY THEY BECAME POPULAR

Most applications need shared state, not a formal architecture.

WHAT TO LOOK FOR IN ONE

Small size Simple mental model Works outside components Good behaviour with server rendering

WHY THAT LAST POINT

A store shared across requests on a server leaks one user's data to another.

WHAT TO CHECK

How the library handles server rendering, before using it there.

WHAT TO ORGANISE

Stores by domain, rather than one store for everything.

WHY

It limits what re-renders, and keeps concerns separate.

WHAT TO AVOID

Putting server data in a general-purpose store Storing derived values State nobody can trace the origin of

WHAT TO PREFER

Selecting narrowly, so components re-render only when what they use changes.

WHAT TO ESTABLISH

A convention for where state lives.


Was this answer helpful?
Back

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


Trustpilot