Why doesn't my code pass tests?

Tell us what’s happening:

Your code so far


const Items = (props) => {
return <h1>Current Quantity of Items in Cart: {props.quantity}</h1>
};

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

Items.defaultProps = {
quantity: 0
};

class ShoppingCart extends React.Component {
constructor(props) {
  super(props);
}
render() {
  return <Items />
}
};

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 6.0.1; SM-N910C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.116 Mobile Safari/537.36.

Challenge: Use PropTypes to Define the Props You Expect

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

Hi @Brightside9, when you are defining which props are required and of what type they are, you should use PropTypes (with a capital P).

MyComponent.propTypes = { handleClick: PropTypes.func.isRequired }

1 Like

Thank you @simonebogni. It gets harder to notice such differences when i’m tired. Thanks again