>

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

Props — Passing Data Into Components

Question 1 / 1

0:00
Core
Medium

A developer builds a ColorList component and adds PropTypes:

import PropTypes from 'prop-types'

const ColorList = ({ colors, onRate }) => (
  <div>
    {colors.map(c => <Color key={c.id} {...c} onRate={onRate} />)}
  </div>
)

ColorList.propTypes = {
  colors: PropTypes.array.isRequired,
  onRate: PropTypes.func.isRequired
}

ColorList.defaultProps = {
  colors: []
}

A teammate renders <ColorList onRate={handleRate} /> with no colors prop. What happens?