DEV Community

Cover image for Redux is "Required"
D\sTro
D\sTro

Posted on

Redux is "Required"

Post #01 🤝

If i have to explain the importance of "Redux" in one line only trust me I cant 😆 but can do that in 3-4 line for sure ⤵️

1️⃣ First of all, redux is not just for React. I have used this with vuejs and angular as well. It's not a framework but a library to manage states(data in short)

2️⃣ some dev think it's good to keep redux away because state and props is easily created inside component. This is wrong!

3️⃣ 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.

4️⃣ You just need to create a store, define action types, create reducer and dispatcher, register subscribers(child components) and that's all to make everything run smooth

5️⃣ Consider redux as a git repository where lots of people push their codes and you can just pull it with one command(subscribers in react term)

I just joined this platform and I'm so excited about it. Thanks for reading 😊

Top comments (2)

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.

Collapse
 
fkrasnowski profile image
Franciszek Krasnowski

These points can be applied to almost every state manager 🙃