Skip to main content

State Management in React App

Types of state

I categorize States in React App into 2 types:

Server StateClient State
WhatData from API fetchingPurely data from client side
Examplesproduct list, details from APIactive state of checkbox, selected theme, language
Libtanstack-queryuseState for local, zustand for global
Notes
  • For client state, please use local state until you need global state.
  • The more global states in your app, the more complex your app gets.

Where to store

The following flow chart visualize where will we store our state:

Source: Generated by FigJam AI

tanstack-query is the new brand of react-query