Override Default Props ---Please explain this

Override Default Props ---Please explain this
0

#1

Tell us what’s happening:

I didn’t understand this topic please explain it.

Your code so far


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.props = {quantity:100} /> 
    { /* change code above this line */ }
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36.

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


#2

It demonstrates how to override default a component’s default props. You do it the same way you assign props normally


#3

Ok, I have got the solution thank your for time.:blush:


#4

**Where is the issue…**please look into it

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.props={quantity:10} />
    { /* change code above this line */ }
  }
};