Is there a way to disable Redux warning: A non-serializable value was detected in the state

Firefox console log

I’m completely aware of the downsides of storing non-serializable values to Redux state. Like the Redux docs say:

If you are okay with things like persistence and time-travel debugging potentially not working as intended, then you are totally welcome to put non-serializable items into your Redux store.

So, I’m just prototyping to try out some ideas. I might refactor the code in the future to eliminate these function objects from state, but at the moment these warnings are just flooding my console, burying other messages I might actually care about.

Is there perhaps some switch to toggle these warnings on/off?

Answer

It’s a redux-toolkit error and the whole error links to documentation that shows how you can disable the errors for specific actions.

https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data

To quote:

However, if you do need to turnoff those warnings, you can customize the middleware by configuring it to ignore specific action types, or fields in actions and state:

configureStore({
  //...
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: {
        // Ignore these action types
        ignoredActions: ['your/action/type'],
        // Ignore these field paths in all actions
        ignoredActionPaths: ['meta.arg', 'payload.timestamp'],
        // Ignore these paths in the state
        ignoredPaths: ['items.dates'],
      },
    }),
})