React - Use PropTypes to Define the Props You Expect

Tell us what’s happening:

i don’t know what i need to do.

Your code so far

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

import PropTypes from 'prop-types';

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

class ShoppingCart extends React.Component {
  constructor(props) {
    super(props);
    this.state = { quantity: 5 }; // o cualquier cantidad inicial
  }
  render() {
    return <Items quantity={this.state.quantity} />
  }
};

Your browser information:

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

Challenge Information:

React - Use PropTypes to Define the Props You Expect

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

hello and welcome back to fcc forum :slight_smile:

  • only use this, and remove that previous “import” statement for “PropTypes”

happy coding :slight_smile:

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