React - Review Using Props with Stateless Functional Components

Tell us what’s happening:

’ The Camper component should include prop types which require the name prop to be of type string’ I get this in test,
.

Your code so far



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


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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0

Challenge Information:

React - Review Using Props with Stateless Functional Components

Welcome to the forum @sidmet92
Please restore this part of the code, as the instructions asked you to only modify the code below a certain line.

The last instruction was:
Finally, define propTypes on the Camper component
Here is your code.

Happy coding

Thank you for your help!

1 Like