React using props23

Tell us what’s happening:
I am wondering why my console is telling me that ‘name’ is not defined even though i have named defined in my Camper component.

Is it becuase the challenge says ‘functional components’ so it needs to be a function compnenet and not a class? would this work if it was not a challenge?

  **Your code so far**

class CampSite extends React.Component {
constructor(props) {
  super(props);
}
render() {
  return (
    <div>
      <Camper/>
    </div>
  );
}
};
// Change code below this line

class Camper extends React.Component {
constructor(props){
  super(props)
}
render(){
  return (
    <div>
      <p>{this.props.name}</p>
    </div>
  )
}
}

Camper.defaultProps = {name:'CamperBot'};

Camper.propTypes.name = {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/98.0.4758.102 Safari/537.36 Edg/98.0.1108.56

Challenge: Review Using Props with Stateless Functional Components

Link to the challenge:

nevermind. i had the Camper.propTypes having an ‘extra’ name. must have left it there

Thanks for anyone who looked anyway

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