Why set both a default prop as well as isRequired?

Tell us what’s happening:
I’m just curious why you would have both a defaultProps as well as making the prop isRequired. If you have a default prop, then there will always be one, so what’s the point in making it required? Is it just for the sake of practicing in the exercise? Or is it a sort of backup system in case one of the two was removed from the code?

Your code so far

class CampSite extends React.Component {
constructor(props) {
render() {
  return (
      <Camper />
// Change code below this line

function Camper(props){
return <p>{props.name}</p>

Camper.defaultProps={ name: 'CamperBot' }

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0

Challenge: Review Using Props with Stateless Functional Components

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.