Redux toolkit multiple slices error

Hi, I’m trying to create the multiple slices but I’m getting the error. The following is the error and the code.

import {configureStore, createSlice} from "@reduxjs/toolkit";

const initialCondition = {isAuthorized:false};

const initialState = {counter:0}

const counterAuth = createSlice({

    name:"auth",

    initialCondition,

    reducers:{

        login(state){

            state.isAuthorized = true;

        },

        logout(state){

            state.isAuthorized = false;

        }

    }

})

const counterSlice = createSlice({

    name:"counter",

    initialState,

    reducers:{

        increment(state){

             state.counter++

        },

         decrement(state){

             state.counter--;

        }

    }

});

const counterStore = configureStore({

    reducer:{counter:counterSlice.reducer, auth:counterAuth.reducer}

});

export const counterAuthActions = counterAuth.actions;

export const counterSliceActions = counterSlice.actions;

export default counterStore;

The following is the error I’m getting in the console.

redux.js:473 Uncaught Error: The slice reducer for key “auth” returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don’t want to set a value for this reducer, you can use null instead of undefined.
at redux.js:473:1
at Array.forEach ()
at assertReducerShape (redux.js:466:1)
at combineReducers (redux.js:531:1)
at configureStore (configureStore.ts:144:1)
at Module…/src/Store/Store.js (Store.js:40:1)
at Module.options.factory (react refresh:6:1)
at webpack_require (bootstrap:24:1)
at fn (hot module replacement:62:1)
at Module…/src/index.js (Counter.js:44:1)

You’ve added something you’ve called initialCondition to the slices configation object. It’s initialState, which you’ve defined but haven’t added.

in the counterAuth,‘initialCondition,’ should be ‘initialState:initialCondition ,’ and in the counterSlice , ‘initialState,’ should be ‘initialState:initialState’. :rofl: