React - Use PropTypes to Define the Props You Expect

TheShoppingCartcomponent should render.
TheItemscomponent should render. // tests completed // console output Uncaught ReferenceError: require is not defined

Your code so far

import React from ‘react’;
import PropTypes from ‘prop-types’;

const Items = (props) => {
return

Current Quantity of Items in Cart: {props.quantity}

;
};

// Define propTypes for the Items component to require quantity as a prop and verify that it is of type number.
Items.propTypes = {
quantity: PropTypes.number.isRequired
};

Items.defaultProps = {
quantity: 0
};

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


### Your browser information:

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0</code>

### Challenge Information:
React - Use PropTypes to Define the Props You Expect
https://www.freecodecamp.org/learn/front-end-development-libraries/react/use-proptypes-to-define-the-props-you-expect

Hello there @surafel1,

  • Please make your post clear and understandable.
  • Add the links

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.