You don't need external libraries for global state management in React

https://prophet-bestman.hashnode.dev/mastering-complex-state-management-with-context-api-and-usereducer

React Context + useReducer - Still to this day my favorite way of managing global state in React, no extra dependencies, no learning curve, it's all there built-in

10 points · 3 comments · view on lemmy.world

3 Comments

RadiantDew@programming.dev · 6 pts · 3y (1 reply)

Just curious - have you applied this in big React applications?

The reason I'm asking is because all context consumers get re-rendered immediately upon context value update. It might be ok for small apps but bigger apps can suffer.

cufta22@programming.dev · -1 pts · 3y

Small to medium this can definitely work, large scale ( ex. Airbnb ) still works better with redux but i still see people misusing redux in smaller apps where you don't really need it

It's not just redux people really like to overengineer stuff nowadays

ElkanNixed@programming.dev · 2 pts · 3y

It really depends on what kind of state you're storing. For UI or other client stuff usually a context provider is enough. For server data/state I started using React Query a lot more. It syncs server data across components that use the same cache key, which is really powerful.