Question 1 / 1
A developer is writing a Redux reducer for the Color Organizer. They receive a bug report: clicking the star rating on a color updates the UI the first time, but subsequent clicks on the same color have no effect. The reducer looks like this:
const colorsReducer = (state = [], action) => {
switch (action.type) {
case 'RATE_COLOR':
const updatedState = [...state]
updatedState.find(c => c.id === action.id).rating = action.rating
return updatedState
default:
return state
}
}
What is the root cause of the bug?