How to combine stores in redux toolkit

Viewed 557

I have multiple projects with the same overall structure, that use a redux store to handle almost every states :

const store = configureStore({
  reducer: {
    users: userSlice.reducer,
    travels: travelSlice.reducer
  }
})

//example reducer
const userSlice = createSlice({
  name: 'users',
  initialState,
  reducers: {
    addUser: (state, action) => {
      state.users.push(action.payload)
    },
    ....
  }
}) 

I made an utils library that will be used by the projects, it has its own store (similar code as above) but we want that each app has only 1 store

Is there a way to combine the 2 stores in 1 ?

0 Answers
Related