DEV Community

Discussion on: Redux is "Required"

Collapse
 
sergiodxa profile image
Sergio Daniel XalambrĂ­

when a component has dependencies on several other component state and suppose you make an axios calls then its tough to update everywhere. This is one of the important aspect of using redux.

Try SWR or React Query. They solve this really well, they give you a global cache for your data (queries) coming from a server without all the work required to use Redux, something like:

const { data, error }= useQuery("current-user", getCurrentUser)
if (error) return <ErrorUI />
if (!data) return <LoadingUI />
return <NormalUI />

Once you use one of these libs your Redux store is so small that you can easily replace it with Context or the equivalent of your UI framework for global/shared data, or even better, keep it local to the component if it's not really needed to be global/shared.