>

CODEMASTERYLAB

IDE PLATFORM
CoursesCommunity BlogsKnowledge GraphQuizzesInterview Prep

Sign in to track progress & earn XP

Sign In Create Account
>
Code Mastery Lab

Code Mastery Lab

Sign In

Modern JavaScript You Need for React — Destructuring, Spread, and Modules

Question 1 / 1

0:00
Core
Medium

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?