如何从Immutable.List中删除

时间:2018-02-19 16:28:26

标签: javascript reactjs redux react-redux immutable.js

为什么deleteIn不适用于List?如何修复它以使数据保持不变?

   import {OrderedMap, Record, List} from 'immutable';

   const ReducerState = Record({
        completedCount: new List([1,2,3])
    });

    const defaultState = new ReducerState();

    export default (tasksState = defaultState, action) => {
        const {type, payload} = action;
        switch (type) {
            case CHECK_TASK:
                return tasksState.deleteIn(['completedCount', payload.id]); // payload.id = 1
        };

    return tasksState;
};

1 个答案:

答案 0 :(得分:0)

我明白了,有必要删除索引而不是元素

const encryptedBuffer =  crypto.publicEncrypt({
  key: publicKey,
  padding: crypto.constants.RSA_PKCS1_PADDING
}, utf8Payload)