【发布时间】:2018-12-12 19:37:34
【问题描述】:
我在 Redux Store 中有状态,我想将所有 isPlaying 更改为 false。我不知道如何以更好的方式做到这一点。这是我到目前为止所做的。
const INITIAL_STATE = {
isPlaying: true,
allLangs: [
{
shortName: 'es',
fullName: "spanish",
order: 0,
isPlaying: false
}, {
shortName: 'pt',
fullName: "portuguese",
order: 0,
isPlaying: false
},
{
shortName: 'gb',
fullName: "english",
order: 0,
isPlaying: true
}
]
}
return update(state,
{
$merge: {isPlaying: false},
allLangs: {
[0]: {
$merge: {isPlaying: false}
},
[1]: {
$merge: {isPlaying: false}
},
[2]: {
$merge: {isPlaying: false}
}
}
});
所以我的问题是:有什么比单独调用所有索引更好的方法吗?
【问题讨论】:
标签: javascript arrays reactjs redux store