英文:
Is it good to store URL object in redux store?
问题
I tried to store the URL object in the react store and it is giving me error that:
在状态中检测到了一个不可序列化的值,在路径中:
Here is the URL reference in my store.
Code Reference:
Is there an alternative way to store URL or how can we fix this error?
英文:
I tried to store the URL object in the react store and it is giving me error that:
A non-serializable value was detected in the state, in the path:
Here is the URL reference in my store.
Code Reference:
Is there an alternative way to store URL or how can we fix this error?
答案1
得分: 1
只返回翻译好的部分:
"正如错误中所指出的,您应该只将可序列化的数据存储在Redux存储中。
只获取href属性如下:
const yourUrl = new URL(...);
console.log(yourUrl.href);
有关更多文档,请访问MDN网站 https://developer.mozilla.org/en-US/docs/Web/API/URL"
英文:
As you have in the error, you should store only serializable data in the Redux store.
Get only the href propery like that:
const yourUrl = new URL(...);
console.log(yourUrl.href);
More documentation here on the MDN Website https://developer.mozilla.org/en-US/docs/Web/API/URL
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论