Placement of default props and this default prop

It is not clear which section a default prop would be set in this example. Besides, there is not a line that sets the default prop to 0.

const Items = (props) => {
return <h1>Current Quantity of Items in Cart: {props.quantity}</h1>
}

Items.defaultProps = {
quantity: 0
}

class ShoppingCart extends React.Component {
constructor(props) {
  super(props);
}
render() {
  { /* Change code below this line */ }
  return <Items quantity={10} />
  //Would this go here?
//const defaultProps = {quantity: 0};
  { /* Change code above this line */ }
}
};

Challenge: Override Default Props

Link to the challenge:

Eureka. Default props are set after variable Items is declared. I was under the influence of constructors and thought this was one, assuming so without reading carefully.

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