React - Use PropTypes to Define the Props You Expect

Tell us what’s happening:

  1. The Items component should include a propTypes check to require a value for quantity and ensure that its value is a number.
    // tests completed
    // console output
    act(…) is not supported in production builds of React, and might not behave as expected.

Your code so far

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

// Correct propTypes definition
Items.propTypes = {
  quantity: PropTypes.number
};

// Default value if no quantity is passed
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

React - Use PropTypes to Define the Props You Expect

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!