(Global) State Management
Global state > Client state & Server state
Last updated
Global state > Client state & Server state
Last updated
Management Solutions
React Query (TanStack Query)
- Fireship (3/2022)
- Tanner Linsley (creator of ) (2020)
“global” state > client state & server state (two different concerns / management techniques)
Where the terms/concepts “client state” and “server state” started becoming more of a thing (rather than just “global state”). Really good video
RQ Documentation:
Management Solutions
, by (2/2022):
(1) useState > prop drilling (-5:03)
(2) useContext (for global (client) state) (-9:21)
Multiple instances of useContext (-10:38)
useReducer (instead of useState) within useContext (-13:45)
useReducer (instead of even reaching for useContext) ()
(3) issues with useContext / one reason for using an actual (3rd party) state manager (useContext = more rerendering than desired) > Zustand (3rd party state manager) ( & beyond)
A good way to implement Zustand / 3rd party state manager (abstraction layer / facade)
Fine-grained updates
This section of the video is largely what convinced me to plan to immediately reach for Zustand vs useContext when I start needing a global (client) state in an app
Zustand:
useContext:
**one way to somewhat difficultly get around this is use-context-selector 30:10 (another 3rd party library from Zustand creator)
**Jack Herrington is another really good YouTube channel guy (he also does a good podcast “React Roundup”)