In my company, all of the projects use at least some kind of global state library like Redux and MobX.
However, the actual usage is limited to storing fetched data, and it lacks any caching logic or mechanism. It's merely used to store the method for fetching data and the property for the fetched data.
Personally, I find this approach redundant because we could instead use something like react-query
, which would not only accomplish the same task but also provide better caching capabilities.
For tasks like theming, we are already using MUI, which offers the <ThemeProvider>
and useTheme()
hook, eliminating the need for additional global state libraries.
Despite my confusion, I understand that there must be reasons for using global state libraries. However, I cannot identify any specific advantages. These libraries continue to have significant weekly downloads, indicating that there is likely a crucial aspect I am overlooking. I would appreciate it if you could share your insights and explain why global state is still necessary in React (in general, not just based on the example I mentioned earlier).