React JS "Use PropTypes to Define the Props You Expect" Why does capitalization work this way for Proptypes?

Hello,

In this lesson : https://www.freecodecamp.org/learn/front-end-libraries/react/use-proptypes-to-define-the-props-you-expect

The solutions is as follows

// change code below this line
  Items.propTypes = {
    quantity: PropTypes.number.isRequired
  };
// change code above this line

However, the following bits of code don’t work. The only thing that has changed in the below snippets of code is the capitalization of the first P in PropTypes.

// change code below this line
  Items.PropTypes = {
    quantity: PropTypes.number.isRequired
  };
// change code above this line
// change code below this line
  Items.PropTypes = {
    quantity: PropTypes.number.isRequired
  };
// change code above this line

Why is it that the P in items.propTypes = has to be i lowercase, but the P in PropTypes.number.isRequired has to be Capitalized? If I switched either one, the test would not accept my answer.

1 Like

JavaScript is case sensitive, same as all programming languages, so those are two completely different things. One is an object called PropTypes which has a load of definitions, and one is a property you’re adding to the object Items called propTypes.

1 Like