Tag Archives: React report error

[Solved] Error: The slice reducer for key “auth“ returned undefined during initialization. If the state pas

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.

Cause: switch (action.type) is not set default

export default function authReducer(state, action) {
    switch (action.type) {
        case SIGNUP:
            return {
                ...state,
                signup: {
                    loaded: false,
                    success: false,
                }
            }
        default:
            return state;    
     }
}