Вы можете сначала получить модифицированный memoryCards
, а затем currentCardType
отдельно, например,
case types.CARD_CHECK: {
let memoryCards = state.memoryCards.map((card, index) => {
if (index === action.index) {
return {
...card,
flipped: !card.flipped
}
}
return card
});
let currentCardType = state.memoryCards[action.index].type; // since your are checking array index with action.index
return {
...state,
memoryCards,
currentCardType
}
}