So I got this one to work, but I’m curious about why my first attempt (below) failed:
Your code so far
class CampSite extends React.Component { constructor(props) { super(props); } render() { return ( <div> <Camper /> </div> ); } }; // change code below this line const Camper = () => { return ( <p>{this.props.name}</p> ); }; Camper.defaultProps = { name: 'CamperBot' }; Camper.propTypes = {name: PropTypes.string.isRequired}
Here, I’m creating
Camper as a variable, not as a class. I’m just curious if someone could elaborate on the difference in react between classes and variables, so I could get a better idea of why we need Camper to be a class in this instance.
Thanks!
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.
Link to the challenge: