State
Management
in React Js
There are basically 2 types of state in
any React application
1. Server Cache
2. UI State
Server Cache
➡️ It's the data that comes from the
server ( through API calls )
➡️ We need to act upon that data
and store it locally / globally in our
React application
Server Cache ( Example )
➡️ React Query
➡️ Apollo Client ( For GraphQL )
➡️ RTK Query ( For Redux )
UI / Client State
➡️ The client state describes the
user actions such as toggle navbar,
open / close modal, change theme
preference, etc.
It's also used to hold values for
component specific task. Example -
"counter"
UI State ( Example )
➡️ useState, useEffect,
useRef Hooks (For smaller projects)
➡️ Context API + Basic Hooks
( For medium projects)
Do you find this post
helpful then please do
share this post with your
connections ;))