Override Default Props.Help

Override Default Props.Help
0

#1

Tell us what’s happening:

Where is my wrong please I need help.

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 />
    { /* change code above this line */ }
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

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


#2

Override the default prop by passing in a value of 10 for quantity


#3

Yes and what can I do?


#4

Your component Items has a prop named quantity. If no quantity prop is passed when rendering the Items component it will set the value of quantity to 0 by default.

This is what is currently happening.

But you want your ShoppingCart component to render an Items component that overrides the default value of quantity

So you can add a prop of quantity={10} to the Item component that is being rendered


#5

const Items = (props) => {
return

Current Quantity of Items in Cart: {props.quantity}


}

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 */ }

}
};

This is my new code but I have some words with red underline what can I do?


#6

Nice, you are close, your syntax is just a bit off.

Sorry I am not going to tell you the answer because you will learn better when you figure it out.

Review this challenge, I think you have already completed it and it shows you how to pass props
https://learn.freecodecamp.org/front-end-libraries/react/pass-props-to-a-stateless-functional-component


#7

My code is right or I should remove somethig or add something.


#8

It is not quite right.

Review this challenge and you will get your asnwer
https://learn.freecodecamp.org/front-end-libraries/react/pass-props-to-a-stateless-functional-component


#9

I saw this challenge before but again I don’t understand please can you help me more.


#10

In that challenge your are passing a prop called date with the Javascript Date object as its value
date={Date()}

In the challenge you are stuck on you want to pass a prop called quantity with a value of 10
quantity={10}


#11

Please learn to properly format your code with 3 backticks before and after your posted code block. You have been told numerous times how to do this in the past.


#12

Oh sheeeeit rando laying down the LAW.

Anyway, if you are still stuck this article might help


#13

So I can’t find the solution I belive I need more help.


#14

I’m not sure how else to explain it.

When I started React I did the codecademy react course first then came to FCC to complete the React challenges here.

there is also a React part 2 on codecademy


#15

I want it tell my code is right or not?


#16

what have you tried since this?