我正在尝试将immutableJS添加到Mern.io. 当我尝试从我的帖子列表中删除帖子然后将其设置回我的状态时,状态不会更新.
case ActionTypes.DELETE_POST :
const removeArray = state.get('posts')
.filter((post) => post._id !== action.post._id)
console.log(removeArray.length)
state.set('posts', removeArray)
console.log(state)
return state;
Run Code Online (Sandbox Code Playgroud)
在这个例子中,如果我有一个5的数组,我应该能够将其过滤掉,然后使用新数组再次设置"posts".我不明白的是我可以从数组中删除对象,removeArray将比state.posts少一个.但是当我控制日志状态时它是一样的.我错过了什么?