What is Redux in ReactJS
In this article, we will know about redux in reactjs and what is the use of redux. Before we learn this concept you know the fundamentals of React. If you are a completer beginner, I highly recommend you to watch this react beginner playlist. In that playlist, they covered in detail all the fundamental concepts in react. Once you are thorough with the basics making sense of react with Redux is going to be much easier.
- It is for JavaScirpt apps
- It is a state container and
- It is predictable
Let’s look at each of these parts separately:
State container means that Redux stores the state of our application. But what exactly do we mean by the state of an application, consider a React app we know the state of a component.
For example :
If we have a login form, the state of the component is simply an object that holds Username, password, and submitting flag to indicate the submit action happening in the background. If we had a list of users to display the state of the component would be an object that contains an array of users. Extending on this knowledge we can say that the state of an application is simply the state represented by all the individual components of that application. This includes the data and the UI logic. If your application is medium to large in size, the state of the application could be something like ‘isUserLoogedin’, ‘username’, ‘profileUrl’, ‘onlineusers’, and ‘isModalOpened’.
React is predictable in what way?
React which is a UI library and Redux which is a state management library. They are independent of each other. To directly use redux in our react application, is a bit confusing and also difficult that is the reason we have the React redux package. React redux is the official redux UI binding library for React, which mean that react redux offers a couple of function that will help you connect your react application with Redux. So, if you are using react and redux together, you should also use react redux to bind the two libraries.