Review Using Props with Stateless Functional Components

Review Using Props with Stateless Functional Components
0

#1

Tell us what’s happening:
The test case fails saying “The Camper component should include prop types which require the name prop to be of type string”.

Your code so far


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

Camper.defaultProps = {name:'CamperBot'};
Camper.propTypes = { 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/66.0.3359.181 Safari/537.36.

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


#2

Re-check and fix this line to pass the test.


#4

Solution to pass the test:

// change code below this line
const Camper = (props) => <p>{props.name}</p>

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