Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling the non-serializable data warning #870

Closed
catamphetamine opened this issue Jan 18, 2021 · 2 comments
Closed

Disabling the non-serializable data warning #870

catamphetamine opened this issue Jan 18, 2021 · 2 comments

Comments

@catamphetamine
Copy link

catamphetamine commented Jan 18, 2021

In my code, when fetching data from the API, I parse all date ISO strings into Dates because it's better this way.

That causes @reduxjs/toolkit to log two error messages:

A non-serializable value was detected in an action, in the path:

A non-serializable value was detected in the state, in the path:

There seems to be no configuration option to disable those error messages.

For anyone coming here from Google, my solution to the issue is:

const consoleError = console.error; // eslint-disable-line no-console
console.error = (...args) => { // eslint-disable-line no-console
  if (args && typeof args[0] === 'string' && args[0].indexOf('A non-serializable value was detected in') > -1) {
    // Ignore.
  } else {
    // Log the error as normally.
    consoleError.apply(console, args);
  }
};
@markerikson
Copy link
Collaborator

markerikson commented Jan 18, 2021

The options for customizing or disabling this are specifically listed in the docs already:

Please use those instead of hacking around overriding console.error.

@catamphetamine
Copy link
Author

@markerikson
Oh, thx

Pony-Hsieh added a commit to Pony-Hsieh/e-commerce-react-2023-01 that referenced this issue Mar 6, 2023
問題:
報錯訊息
A non-serializable value was detected in an action

解法:
在 `src/app/store.js` 中的 middleware 新增相對應設定即可

參考文章:
1. redux-toolkit 报无法序列化 Warning A non-serializable value was detected in an action
https://blog.csdn.net/m0_48474585/article/details/121462589

2. Disabling the non-serializable data warning
reduxjs/redux-toolkit#870
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants