React: Use PropTypes to Define the Props You Expect

Tell us what’s happening:
I’m not understanding whats happening… I saw the official documentation and they say what I do. Can you help me please? :slight_smile:

type or paste code here
``import PropTypes from 'prop-types';

class Greeting extends React.Component {
  render() {
    return (
      <h1>Hello, {}</h1>

Greeting.propTypes = {
  name: PropTypes.string
**Your code so far**


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

// change code below this line
Items.propTypes = { quantity: PropTypes.number }
// change code above this line

Items.defaultProps = {
  quantity: 0

class ShoppingCart extends React.Component {
  constructor(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/66.0.3359.139 Safari/537.36.

Link to the challenge:

1 Like

I think that the answer should be

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

but this isn’t working either. Imports don’t work in the browser, so we do have to use the PropTypes object on React. Not sure why this isn’t working.


Yes, it is. Thank you soo much! :slight_smile:

As future reference for others, it worked for me by using PortableStick’s code minus the " React. " portion when defining “quantity”