Review Using Props with Stateless Functional Components- coding challenge

Review Using Props with Stateless Functional Components- coding challenge
0

#1

Tell us what’s happening:

can’t figure out the error.
Thank you for the help!

Your code so far


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

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


Camper.defaultProps = { name: 'CamperBot' }

Camper.propTypes = { name: PropTypes.string.isRequired }

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/review-using-props-with-stateless-functional-components


#2

You do not need to reference this. You just need to reference the props.name


#3

I got the same problem, why we don’t need this at this point.


#4

Because Camper is a Stateless Functional Component (SFC) vs. a React Component. Only React Components reference this.state or this.props. SFCs only receive a props object, so you only have to reference props.something.