-1

Are there reasons why one would use both redux and useContext in their APP?

If so, what are they? Can you give examples of when to use either?

  • 2
    This is far too broad a question for SO. If you just Google "redux vs. context" you can find dozens of articles and videos that go into depth about this, the info is already there. Which ones to use are based on their differences vs. your project's requirements – Jayce444 Jul 13 '22 at 04:44

2 Answers2

2

It is not suggested to use both redux and context api in single app.

Both context and Redux has advantages while developing the application in their own way. Depending upon the use case you need to decide whether to go with context or redux.

Context

If the application is smaller and you need to have a centralized store that needs to store and access the datas. You can use context api. But the code will not be that organised when compared to redux.

The below reference will provide you an outline on creating the context,

https://reactjs.org/docs/context.html#reactcreatecontext

The below will provide you the reference on using the context,

https://reactjs.org/docs/hooks-reference.html#usecontext

Redux

If the application you are developing is bigger or enterprise level application. You can go with redux which provides more optimized code structure compared to context api.

If you want to integrate and use redux. Use reduxtoolkit for simple and elegant usage.

Use the below link for reference,

https://redux-toolkit.js.org/introduction/getting-started

Sujith Sandeep
  • 1,185
  • 6
  • 20
1

Both are excellent tools for their own specific niche, Redux is overkill just to pass data from parent to child & Context API truly shines in this case. When you have a lot of dynamic data Redux got your back! To answer your question Yes you can use them both in the same react app but there is no reason to do so and it is recommended to use one of them depending on your needs

monim
  • 3,641
  • 2
  • 10
  • 25