Use PropTypes to Define the Props You Expect--The Items component should include a propTypes check that requires quantity to be a number error

Tell us what’s happening:

Hi,
I am getting this error and I am not sure how to resolve it :
The Items component should include a propTypes check that requires quantity to be a number.

I thought that by having: Items.propType = {
quantity: PropTypes.number.isRequired
} . it will solve it but I am getting an erroe stating that The Items component should include a propTypes check that requires quantity to be a number.

Your code so far




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

Items.propType = {
  quantity: PropTypes.number.isRequired
}


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 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:

here is the solution to your question

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

Items.propTypes = {
  quantity: PropTypes.number.isRequired
}


Items.defaultProps = {
  quantity: 0
};

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

simple misspelling

1 Like