DEV Community

Discussion on: How To Use Redux in your React TypeScript App

Collapse
 
soorajsnblaze333 profile image
Sooraj (PS) • Edited

This is a great way of explaining :). Also do take a look at React Context. It is like an inbuilt redux store for React and it is much easier to setup and use than redux :)

Collapse
 
markerikson profile image
Mark Erikson

Context and Redux are very different tools that solve different problems, with some overlap.

Context is not a "state management" tool. It's a Dependency Injection mechanism, whose only purpose is to make a single value accessible to a nested tree of React components. It's up to you to decide what that value is, and how it's created. Typically, that's done using data from React component state, ie, useState and useReducer. So, you're actually doing all the "state management" yourself - Context just gives you a way to pass it down the tree.

Redux is a library and a pattern for separating your state update logic from the rest of your app, and making it easy to trace when/where/why/how your state has changed. It also gives your whole app the ability to access any piece of state in any component.

So, yes, you can use both of them to pass data down, but they're not the same thing.

For more details, see my posts Redux - Not Dead Yet! and React, Redux, and Context Behavior.