0

Let's say I have two reducers imported from two slices authSlice and uiSlice

import { configureStore, ThunkAction, Action } from "@reduxjs/toolkit"
import authReducer from "./auth/authSlice"
import uiReducer from "./ui/uiSlice"

export const store = configureStore({
  reducer: {
    auth: authReducer,
    ui: uiReducer,
  },
})

I am able to reset state of authSlice using this code in reducers

...
const initialState: InitialState = {
  permissions: [],
  loggedIn: false,
}

...
    logout: () => {
      return initialState
    },
...

But I haven't been able to find a way to reset to all initialStates in all slices. I want to be able to reset uiSlice and authSlice to their particular initialStates.

  • Does this answer your question? [Reset state to initial with redux-toolkit](https://stackoverflow.com/questions/59424523/reset-state-to-initial-with-redux-toolkit) – DannyMoshe Mar 01 '23 at 19:39
  • Thank you @DannyMoshe but this question is not related to my answer. But there is one answer in there but it does not work for me. Redux maintainer Mark Erikson will soon be answering my question. I have tagged him somewhere after he asked me to ask a separate question because what I am asking is completely different. Waiting for him. – Piyush Aggarwal Mar 02 '23 at 16:45

0 Answers0