Posts

Showing posts with the label when to use context api

React Context API vs Redux - Which one to use

Image
At some point while learning React most of the people think whether React Context API is a replacement for Redux, we are often confused that when should we go for Context API and when should we go for Redux. Moreover what could be the pros and cons if we select each. So in this article we are going to compare React Context API and Redux also we will try to see when each are useful. What is Redux  According to definition, Redux is a predictable state container for Javascript applications. Redux helps us manage the state of the application. From react perspective React offers no solution which allows us to have a global state, so that we can share states among components. Redux solves this problem and it's a good fit for react. What is Context React Context API on the other hand , is a component structure provided by React framework which allows us to share specific forms of data across its children. When Redux can be replaced by React Context API  If we are...