Review Using Props with Stateless Functional Components (same error, two different types of code)

Ayyy 2 posts in 1 day, i’m on a roll. So i’ve had 2 other coders look at this, and wrote it in 2 different ways, all coming up with the same error:

“The Camper component should include prop types which require the name prop to be of type string.”

Everything else is passing. Not to mention the syntax for that error is “Camper.PropTypes = {name: PropTypes.string.isRequired};”

So whats going on here?

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 (
      <p>
      {this.props.name}
      </p>
    );
  }
}

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

Your browser information:

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

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

It looks like you’re missing the propTypes and default props declarations. you can find more information about that in the react docs here: https://reactjs.org/docs/typechecking-with-proptypes.html

1 Like

carefully check your spelling here, match it with the lesson here if you have to

1 Like

ah, once again it all comes down to a capitalized “p”. Thanks for the help guys!