React: require is not Defined

Tell us what’s happening:
Initially I received an error saying that propTypes is not defined.
I was able to fix this by using the import on line 6
Currently I’m getting an error saying that require is not defined either, but I’m unsure where this would be found in the exercise. I tried adding “require” to the curly braces of the import and still get the same error. Where should it be defined? It seems like a version issue, but I just don’t know how to fix it in the context of this exercise.

Your code so far


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

// change code below this line
import React, { propTypes } from 'react';

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 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:

There is no need for you to do any imports in these exercises. It’s already being imported behind the scenes for you.

I guess if that’s the case, then I’m not sure why I’m getting an error that propTypes is not defined when I remove that line. Nothing is rendering, either, but I’m not supposed to be changing anything else.

This should be PropTypes instead of propTypes. When it’s a stand alone, it has to be capital letter.

1 Like

Definitely writing that one down. Thanks a lot.