>

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

Functional Tools — Map, Filter, Reduce, and Composition

Question 1 / 1

0:00
Core
Medium

A developer needs to update the rating on a specific color in a Redux reducer. They write:

case 'RATE_COLOR':
  return colors.map(color => {
    if (color.id === action.id) {
      color.rating = action.rating
    }
    return color
  })

The ColorList component re-renders (the array reference changed), but the matched color's displayed rating doesn't update. What is wrong and what is the correct fix?