在redux中使用动态键更新不可变状态

在redux中使用动态键更新不可变状态,redux,immutable.js,Redux,Immutable.js,我有这个初始状态 const initialState = Immutable.fromJS({ list: [], entities: {}, something: { otherOne: false, otherTwo: false, }, }); 我想用如下函数更新对象某物: [UPDATE_SOMETHING]: (state, { key }) => { // <== key is the name of the nested props

我有这个初始状态

const initialState = Immutable.fromJS({
  list: [],
  entities: {},
  something: {
    otherOne: false,
    otherTwo: false,
  },
});
我想用如下函数更新对象
某物

[UPDATE_SOMETHING]: (state, { key }) => { // <== key is the name of the nested props
    return state.merge({
      filterBy: {[key]: !state.get('key')},
    });
  ),
[UPDATE_SOMETHING]:(state,{key})=>{//
像那样的东西能帮上忙吗

类似的东西可能会有所帮助?

这是什么?=>“[语法]:”---我想这样做,但不知道第一部分代表什么。@zero\u cool检查这个:这是什么?=>“[语法]:”---我想这样做,但不知道第一部分代表什么。@zero\u cool检查这个:
[UPDATE_SOMETHING]: (state, {key}) => {
  const something = state.get('something').withMutations(s => {
    s.set(key, !s.get(key));
  });
  return state.set('something', something);
),