我如何持续嵌套的redux商店
我想坚持我的redux商店的嵌套对象。我尝试了 https://github.com/rt2zz/redux-persist 包装在我的情况下工作。我想知道是否可以定义这样的白名单:'user.statuses.verification.isdone'
这是我的商店:
{
user: {
statuses: {
verification: { isPending: true, isDone: false },
activation: { isPending: true, isDone: false },
set1: { isPending: true, isDone: false, refNumber: xxx },
set2: { isPending: true, isDone: false, refNumber: xxx },
},
},
}
我只想在每个状态和“ refnumber”中坚持“ isdone”。 谁能帮我吗?
我已经尝试过如Redux持续文档中所述的嵌套持续存在 httpps://github.com/rt2zz zzz /redux-persist#嵌套派者,但看起来它的限制为2级。
I want to persist nested object of my redux store. I tried https://github.com/rt2zz/redux-persist package but it doesn't work in my case. I wonder if it's possible to define a whitelist like this: 'user.statuses.verification.isDone'
This is my store:
{
user: {
statuses: {
verification: { isPending: true, isDone: false },
activation: { isPending: true, isDone: false },
set1: { isPending: true, isDone: false, refNumber: xxx },
set2: { isPending: true, isDone: false, refNumber: xxx },
},
},
}
I want to persist only "isDone" in every of statuses and "refNumber".
Can anyone help me?
I already tried nested persist as described in redux persist documentation https://github.com/rt2zz/redux-persist#nested-persists but looks like it has a limitation to 2 levels.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试了这 https://stackoverflow.com/a/71616665 ,它运行得很好。 在此示例中,您可以看到黑名单,但您只需要用白名单替换它即可。
I tried this https://stackoverflow.com/a/71616665 and it works perfectly. In this example you can see the blacklist but you just need to replace it with the whitelist.
您需要使用这个包: https://github.com/edy/redux-persist -transform-filter
“问题”已经得到解决,它更多的是一个精确的实现选择,而不是维护者认为的问题,并且您有几种不同的方法来解决它:
redux-persist - 如何将嵌套状态列入黑名单/白名单
You need to use this package: https://github.com/edy/redux-persist-transform-filter
The "issue" has already been addressed, it's more a precise implementation choice, not an issue according to the maintainers, and you have several different ways to address it:
redux-persist - how do you blacklist/whitelist nested state