我当前的状态是这样的对象
{active: true, dateAdded: "02-07-2019", endEpoch: "02-07-2019", name: "pics"}
我的减速器
export default (state = initial_state, actions) => {
switch (actions.type) {
case SUBREDDIT_SELECTED:
{
return { ...state,
selected_sub: actions.payload
}
}
break;
case EPOCH_CHANGED:
{
return { ...state,
selected_sub: actions.payload
}
}
break;
default:
return state;
}
}
如何更新状态的endEpoch属性?
答案 0 :(得分:0)
您已经完成了自己想做的事情。要更新endEpoch
,请执行
case EPOCH_CHANGED:
{
return { ...state,
endEpoch: actions.payload
}
}
break;
传播state
将所有道具保留在原处。并更改endEpoch
。