Review Using Props with Stateless Functional Components - missing semicolon

Tell us what’s happening:
SyntaxError: unknown: Missing semicolon. (3:10)
NOt able to determine where and why.

  **Your code so far**

const Camper=(props)=>{

render(){
  <div>
    <p>
      {props.name}
    </p>
  </div>
}





Camper.propTypes={name:PropTypes.string.Isrequired};
Camper.defaultProps={name: 'CamperBot' };

}

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


  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36.

Challenge: Review Using Props with Stateless Functional Components

Link to the challenge:

I think it’s just confused.


const Camper=(props)=>{

render(){
  <div>
    <p>
      {props.name}
    </p>
  </div>
}

First of all, a functional component doesn’t have a render method - it can’t have any methods. Secondly, you’re not returning anything. I would expect either:

const Camper = props => {
  return (
    <div>
      <p>
        {props.name}
      </p>
    </div>
  )
}

or

const Camper = props => (
  <div>
    <p>
      {props.name}
    </p>
  </div>
)
1 Like

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