Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Redux Toolkit warns that a non-serializable value is in an action or state

ErrorA non-serializable value was detected in an action, in the path: `payload.dueDate`

Short answer

Redux Toolkit logs this warning in development when an action or the state holds something that is not plain data: a Date, class instance, Map, Set, function or Promise. Read the path in the message, convert the value (for example with toISOString), or ignore that one path or action type.

  • Applies to Redux Toolkit 2.x, React-Redux 9, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the path in the console message. It names the exact field that holds the bad value, and the value printed after it tells you its type.

    // Browser console: the warning ends with the path and the value, e.g. payload.dueDate
  2. 2Match what you see, then jump to its fix

    1. 1The path points at a field you build yourself, such as payload.dueDateA Date, class instance, Map, Set, function or Promise went into an action or stateFix
    2. 2The same path warns on every dispatch and you accept the trade-offOne known path or action type must carry a non-serializable valueFix
    3. 3Warnings mention action types such as persist/PERSIST or persist/REHYDRATEredux-persist dispatches its own actionsFix

What does the error look like?

  • A non-serializable value was detected in an action, in the path: `payload.dueDate`
  • A non-serializable value was detected in the state

Cause 1 of 3

A Date, class instance, Map, Set, function or Promise went into an action or state

1Check

By default the check accepts undefined, null, strings, booleans, numbers, arrays and plain objects; Dates, Maps and other class instances fail.

grep -rn "new Date\|new Map\|new Set" src/features/

2Fix

Convert before dispatching: store dueDate.toISOString() instead of a Date, a plain object instead of a class instance, and keep functions and Promises out of actions.

dispatch(taskAdded({ title, dueDate: dueDate.toISOString() }));
// rebuild the Date where you display it: new Date(task.dueDate)

3Verify

Dispatch the action again and watch the console stay quiet.

npm run dev

Confirmed by redux.js.org

Did this fix it?

Cause 2 of 3

One known path or action type must carry a non-serializable value

1Check

The docs say this should be rare, and such payloads should not reach state through a reducer. If it is truly needed, limit the exception.

grep -rn "serializableCheck" src/

2Fix

Ignore the specific action type or path instead of disabling the check.

const store = configureStore({
  reducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: {
        ignoredActions: ['your/action/type'],
        ignoredActionPaths: ['meta.arg', 'payload.timestamp'],
        ignoredPaths: ['items.dates'],
      },
    }),
});

3Verify

The warning for that path is gone and warnings for other fields still appear.

npm run dev

Confirmed by redux.js.org

Did this fix it?

Cause 3 of 3

redux-persist dispatches its own actions

1Check

Persistence libraries dispatch their own actions and some store values like timestamps or Promises. Check whether redux-persist is in package.json.

grep -n "redux-persist" package.json

2Fix

Ignore all the action types redux-persist dispatches.

import { FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER } from 'redux-persist';

getDefaultMiddleware({
  serializableCheck: {
    ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
  },
})

3Verify

Reload the app; persist actions no longer warn.

npm run dev

Confirmed by redux.js.org

Did this fix it?

How do I stop it coming back?

  • Store IDs and ISO strings in Redux; build Dates and class instances at the edge where you need them.
  • Leave the serializability check on; the Redux docs encourage keeping it active.
  • When you must make an exception, name the exact path or action type.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.