Can we use store from different libraries together in react project?

81 Views Asked by At

Right now we are using easy peasy in our project, now we want to remove easy peasy store gradually and replace it with reduxtoolkit. Can we use stores with different libraries in react? Or is any alternative way to deal with this situation.

Tried below which is not working:

**Creating store out of reduxtoolkit**

import { configureStore,combineReducers } from "@reduxjs/toolkit";
import appReducer from "./slice/appReducer";

const rootReducer= combineReducers({
  app: appReducer,
});


const store = configureStore({
  reducer: rootReducer,
});


**For easy peasy** 
import models from './models';
import { createStore } from 'easy-peasy';

const store = createStore(models);

**In main file**
  <Provider store={store }>
        <Provider store={reduxStore }>
          <App/>
        </Provider>
  </Provider>

**It is failing with Error:**
easy-peasy.esm.js:93 Uncaught TypeError: store.getActions is not a function

1

There are 1 best solutions below

0
On

Basically Missing step from my side was Importing Provider from correct package.

import { Provider as ReduxProvider } from "react-redux";
import { StoreProvider as Provider } from 'easy-peasy';

 <ReduxProvider store={reduxStore }>
        <Provider store={easyPeasystore }>

Changing my code with above line helped me in solving problem.