>

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

Connecting Redux to React — Provider and connect

Question 1 / 1

0:00
Core
Medium

A developer creates a ColorCount container:

const mapStateToProps = state => ({
  count: state.colors.length
})

export const ColorCount = connect(mapStateToProps)(({ count }) => (
  <p>{count} colors</p>
))

After dispatching SORT_COLORS (which only changes state.sort, not state.colors), the developer expects ColorCount to skip re-rendering since count didn't change. They add a console.log and confirm no extra re-render occurs. A teammate insists this must be a bug and that ColorCount should re-render whenever any state changes. Who is correct, and why?