如何将以下代码转换为ES6 :(尤其是case ActionTypes.GetInviteFulfilled: {
const { host, agenda, guests } = action.invite;
const newState = Object.assign({}, state, {
inProgress: false,
success: 'Got invite.',
host,
agenda
});
newState.guests = [];
if (guests) {
newState.guests = Object.keys(guests).map(k => guests[k]);
}
return newState;
}
{{1}}
答案 0 :(得分:1)
这可能对您有用:
case ActionTypes.GetInviteFulfilled: {
const { host, agenda, guests } = action.invite;
return {
...state,
inProgress: false,
success: 'Got invite.',
host,
agenda,
guests: guests ? Object.keys(guests).map(k => guests[k]) : [],
};
}