React - Review Using Props with Stateless Functional Components

Not able to solve this challenge of react class-based components
Please help me resolve the below error
Error : Uncaught ReferenceError: require is not defined

  **Your code so far**
import PropTypes from 'prop-types'
class CampSite extends React.Component {
constructor(props) {
  super(props);
}
render() {
  return (
    <div>
      <Camper name='hsajkakjs'/>
    </div>
  );
}
};
// Change code below this line
const Camper = props => <p>{props.name}</p>
Camper.defaultProps={
name:'CamperBot'
}
Camper.propTypes={
name:PropTypes.string.isRequired
}


  **Your browser information:**

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

Challenge: React - Review Using Props with Stateless Functional Components

Link to the challenge:

I can’t see the issue however the documentation specifically has a section for isRequired in their Typechecking examples that may help.
Prototype typechecking

As it stands, you aren’t defining require anywhere in your code so possibly an issue with React trying to reference a behind the scenes function in one of the imports and can’t resolve it due to a change in React that’s no longer supported in the context of the task?

Totally guessing and I could be super off but I’ve linked the documentation either way, hopefully it helps!

PropTypes is already there try to log(PropTypes)

1 Like

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