我有这个减速器。
case UPDATE_ENDPOINT:
return <IState>state.map(endpoint =>
endpoint.ocid === action.endpoint.ocid
? {
...endpoint,
name: action.endpoint.name,
hostname: action.endpoint.hostname,
origin: action.endpoint.origin,
originType: action.endpoint.originType,
originValidation: action.endpoint.originValidation,
}
: endpoint
);
假设在我的动作有效负载中我只有endpoint.name
and endpoint.hostname
,那么减速器会将有效负载中未传递的值设置为undefined
。如何让reducer 只更新动作有效负载中的值,而让不在动作有效负载中的值保持不变?