How to fix Reducer returned undefined after action, check your action type in React

ReactBEGINNERMEDIUMUpdated Dec 10, 2025ยท 113 views

This error occurs when a Redux reducer returns undefined instead of a valid state. It's a common mistake in Redux applications that can be fixed by ensuring reducers always return a defined state, even for unrecognized actions.

Quick fix

Fixes Reducer returned undefined after action, check your action type

function myReducer(state = initialState, action) {
  switch (action.type) {
    case 'SOME_ACTION':
      return { ...state, ...action.payload };
    default:
      return state; // Always include this default case
  }
}
  1. Check for missing default case in reducer
  2. Verify all action cases return a state
  3. Provide initial state with default parameter
  4. Test with combineReducers
react โ€” error
function myReducer(state = initialState, action) {
switch (action.type) {
case 'SOME_ACTION':
return { ...state, ...action.payload };
default:
return state; // Always include this default case
}
}
Reducer returned undefined after action, check your action type

What this error means

The "Reducer returned undefined" error happens when a Redux reducer function does not return a proper state value for a dispatched action. Redux requires that reducers always return a defined state object. This error typically indicates that the reducer is missing a default case in a switch statement or has an early return statement that doesn't provide a state value.

Typical symptoms

  • Redux throws an error in the console: "Reducer returned undefined when handling action"
  • Application state becomes undefined, causing components to break
  • UI fails to update after dispatching certain actions
  • Error occurs when using combineReducers() with improperly written slice reducers

Common causes

  1. Missing default case in a reducer switch statement
  2. Forgetting to return state in one of the action cases
  3. Using early return statements without providing a state value
  4. Reducer function not providing initial state when state is undefined
  5. combineReducers() detecting that one of the slice reducers returned undefined

How to fix "Reducer returned undefined after action, check your action type"

1Check for missing default case in reducer

Ensure every reducer has a default case that returns the current state:

javascript
function myReducer(state = initialState, action) {
  switch (action.type) {
    case 'SOME_ACTION':
      return { ...state, ...action.payload };
    default:
      return state; // Always include this default case
  }
}
2Verify all action cases return a state

Check each case in your switch statement to ensure it returns a proper state value:

javascript
// Incorrect - missing return
case 'UPDATE_DATA':
  state.data = action.data; // This doesn't return!
  break;

// Correct - returns new state
case 'UPDATE_DATA':
  return { ...state, data: action.data };
3Provide initial state with default parameter

Use ES6 default parameters to ensure the reducer always has an initial state:

javascript
// Good - provides default initial state
function reducer(state = { count: 0 }, action) {
  // reducer logic
}

// Also acceptable - explicit check
function reducer(state, action) {
  if (state === undefined) {
    return { count: 0 };
  }
  // rest of reducer
}
4Test with combineReducers

If using combineReducers, ensure all slice reducers follow the rules:

javascript
import { combineReducers } from 'redux';

const rootReducer = combineReducers({
  todos: todosReducer, // Must never return undefined
  visibility: visibilityFilterReducer // Must never return undefined
});

// Each reducer must handle undefined state by returning initial state
function todosReducer(state = [], action) {
  // ...
}
5Use Redux DevTools for debugging

Install Redux DevTools extension and inspect the action that causes the error:

1. Open browser DevTools
2. Go to Redux tab
3. Check which action triggered the error
4. Examine the reducer handling that action

This helps identify exactly which reducer is returning undefined.

Advanced notes

Redux's combineReducers utility performs a development check that throws this error when any slice reducer returns undefined. This is a safety feature to catch common mistakes early. In production builds, this check may be omitted for performance, but the underlying issue could still cause bugs. Always ensure reducers are pure functions that never return undefined, mutate state, or have side effects.

Frequently asked questions

What does "Reducer returned undefined after action, check your action type" mean?
The "Reducer returned undefined" error happens when a Redux reducer function does not return a proper state value for a dispatched action. Redux requires that reducers always return a defined state object. This error typically indicates that the reducer is missing a default case in a switch statement or has an early return statement that doesn't provide a state value.
How do I fix "Reducer returned undefined after action, check your action type"?
This error occurs when a Redux reducer returns undefined instead of a valid state. It's a common mistake in Redux applications that can be fixed by ensuring reducers always return a defined state, even for unrecognized actions.
What causes "Reducer returned undefined after action, check your action type"?
Missing default case in a reducer switch statement Forgetting to return state in one of the action cases Using early return statements without providing a state value
Is the "Reducer returned undefined after action, check your action type" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading