DEV Community

Ishan Tiwari
Ishan Tiwari

Posted on

Why should you use Redux

You may find react's state and props system useful but here are some reasons for you to use redux instead.

React seperates things

React is made on the core fundamenatals of separation of concerns.
React thinks that the Header component needs not know what is going on in the footer. It should better mind its own business.
That means if you are using react, and are currently in the header component you should not be knowing what is there in the footer. Well there are a few ways to know what is going on in the footer like event emitters and all those hectic stuff, but you should better use Redux

React is component based

React manages things on a component level. If you are using react for say a blog application provided that each blog is a single component and it fetches some data from a backend api and displays it to the user. After the user has read the blog you want to show him some content related to the blog. You will again call some api and fetch the content in this blog. Let's say he clicks on some other blogs and the same thing happpens you would notice that the api is being called again and again, because the component is getting re rendered with updated values.
You can deal with this code reuse if you had a large heap of data where everything is stored and take it out everytime the blog re-renders. That would do the same thing but consume less data.

Discussion (2)

Collapse
ishanpro profile image
Ishan Tiwari Author • Edited

Sorry guys I should have named this post why should you use redux with react

Collapse
ceoshikhar profile image
Shikhar Sharma

Ummm what?