Skip to content

Instantly share code, notes, and snippets.

@codenickycode
Created January 3, 2023 17:24
Show Gist options
  • Save codenickycode/f4975492cf1b16b24e012a81d545daad to your computer and use it in GitHub Desktop.
Save codenickycode/f4975492cf1b16b24e012a81d545daad to your computer and use it in GitHub Desktop.
[React: State Management Cheat Sheet] A rule of thumb for state management in React #react #state-management

Adapted from RemcoProgrammer's answer here:

Use Case Solution Example
Backend Cache React Query, Apollo Client fetch response
Navigation State React Router URL, params, history state
Component State (and subtree) useState, custom hooks is this thing currently open, what are the form contents and errors, what page of the table are we looking at
Unchanging Global State useContext auth, theme, language choice
Changing Global State Redux, Zustand dashboard data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment