React - Use PropTypes to Define the Props You Expect

Tell us what’s happening:

I’m encountering a compile time error, I wonder why. Is it due to incorrect syntax?

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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

React - Use PropTypes to Define the Props You Expect

Hi @KoduFCC

Yes, the red underline indicates a syntax error.

image
h

Have a look at the sample code in the instructions.

Once you remedy that, there is another error.

Happy coding

Fixed the syntax error, but now I’m getting a runtime error.

Please share your updated code and the error, if you want help with it?

Hard to give feedback when all you are sharing is “I’m getting a runtime error”

Hi @KoduFCC

image

Check for a typo.

Happy coding