gpt4 book ai didi

javascript - 有没有办法禁用 Redux 警告 : A non-serializable value was detected in the state

转载 作者:行者123 更新时间:2023-12-05 09:31:22 25 4
gpt4 key购买 nike

Firefox console log

我完全了解将不可序列化的值存储到 Redux 状态的缺点。喜欢 Redux docs说:

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.

所以,我只是制作原型(prototype)来尝试一些想法。我可能会在未来重构代码以从状态中消除这些函数对象,但目前这些警告充斥着我的控制台,埋没了我可能真正关心的其他消息。

是否有一些开关可以打开/关闭这些警告?

最佳答案

这是一个 redux-toolkit 错误,整个错误都链接到说明如何为特定操作禁用错误的文档。

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

引用:

However, if you do need to turnoff those warnings, you can customize themiddleware by configuring it to ignore specific action types, or fields inactions 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'],
},
}),
})

关于javascript - 有没有办法禁用 Redux 警告 : A non-serializable value was detected in the state,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68794194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com