case 'SOME_ACTION':
return {
...state,
contents: state.contents.map(
(content, i) => i === 1 ? {...content, text: action.payload}
: content
)
}
-------------------------------------------------------------
function handleChange(value) {
const updateArray = userVotes.map(
(item, i) => item.id === id ? {...item, score: value}
: item
)
setUserVotes(updateArray)
}
state.contents[1].text = action.payload;
return {
...state,
contents: state.contents.map(
(content, i) => i === 1 ? {...content, text: action.payload}
: content
)
}
case 'SOME_ACTION':
return {
...state,
contents: state.contents.map(
(content, i) => i === 1 ? {...content, text: action.payload}
: content
)
}