Use Default Props 5

Use Default Props 5
0

Tell us what’s happening:
I am so confused on this lesson. What am I doing wrong here? I’m so confused about it. I tried looking at the hint, but that didn’t work at all. It said there’s invalid errors, which I cannot figure out what those errors are at all.

Your code so far


const ShoppingCart = (props) => {
  return (
    <div>
      <h1>Shopping Cart Component</h1>
    </div>
  )
};
// change code below this line
itemName.defaultProps = {
  prop-x: value,
  prop-y: value
}
ShoppingCart.defaultProps{
  items = 0
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36 Avast/75.0.1447.81.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/use-default-props

First of all, why are you including the above for this challenge. No instructions tell you to do this.

Regarding the above code, you need to look at the example in the challenge description and follow the same syntax. You are supposed to assign an object to ShoppingCart.defaultProps. Since it is an object, you must assign values to properties using the correct syntax.

I got it now, after a few tries. I wasn’t sure that the example given would be the correct way to create the code.