The point of redux and useContext is so that state variables can be persist and be shared across components. localStorage and sessionStorage already do this. So what does redux and useContext add that aren't already present?
Asked
Active
Viewed 404 times
-2
1 Answers
4
That is because you don't need to store everything into persistent storages like session or local storage. Mainly Redux/useContext is to organise application runtime state. It is by default in memory store that only lasts until you refresh or close your app. But Redux can be extended to use local storage for the persistent data(check redux-persist) where you will need to store them even after browser tab is closed.
If you are planning to server rendering your app then go for Redux not React Context API. Because Redux has supported APIs to do rehydration. When using Redux then use with Redux Tool kit where it enforces best practices.

Amila Senadheera
- 12,229
- 15
- 27
- 43