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
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
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?
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
My code is right or I should remove somethig or add something.
I saw this challenge before but again I don’t understand please can you help me more.
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}
Oh sheeeeit rando laying down the LAW.
Anyway, if you are still stuck this article might help
Klaudia
August 19, 2018, 11:49am
13
So I can’t find the solution I belive I need more help.
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
I want it tell my code is right or not?
what have you tried since this?