React - Use PropTypes to Define the Props You Expect

Tell us what’s happening:
Describe your issue in detail here.
It still say that I need to
The

ShoppingCart

component should render. The

Items

component should render.
ReferenceError: require is not defined
Your code so far

import PropTypes from 'prop-types';

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

Items.defaultProps = {
  quantity: 0
};

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

class ShoppingCart extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return <Items />
  }
};
ReactDOM.render(<ShoppingCart />, document.getElementById('root'));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0

Challenge: React - Use PropTypes to Define the Props You Expect

Link to the challenge:

Remove the import, it is handled for you by the challenge.


I realize the note about the import might be a bit misleading but it is just talking about how you would do it in a real project.

1 Like

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