Redux and Context API use together in same React Native project

Viewed 768

Can we use Redux and Context API in the same React Native project? Is there any way or is there any issue if we use them together?

Actually, I want to implement authentication with the Context API and for other state management I want to use Redux Toolkit.

1 Answers

It is possible to use both in a project but unnecessary. You can experience the simple part of redux with useReducer in React. This document explains this. It uses Provider to keep context API and redux states. In your case, this will probably be the case. follow this code:

<Provider store={reduxStore}>
 <Context.Provider value={contextValue}>
  <App/>
 </Context.Provider>
</Provider>
Related