First of all The directory structure is as follows
├─redux
│ │ store.js
│ │
│ └─slices
│ userSlice.js
store.js
import { configureStore, combineReducers } from "@reduxjs/toolkit";
import userSlice from "./slices/userSlice";
const rootReducer = combineReducers({
userSlice,
});
const store = configureStore({
reducer: rootReducer,
});
export default store;
userSlice.js
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
loginState: false,
accessToken: "",
userId: "",
};
const userSlice = createSlice({
name: "userReducer",
initialState,
reducers: {
setLogin: (state, action) => {
state.loginState = true;
state.accessToken = action.payload;
},
},
});
export const { setLogin } = userSlice.actions;
export default userSlice;
Each code is as follows
I need a few more reducers, so I used a combineReducer and, I connected the reducer through configureStore, but the following error continues to occur
Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.
I don't know which one is the problem.