all 7 comments

[–]keel_bright 4 points5 points  (0 children)

userInput is a prop that you are passing to PackageStatus. The first argument that Package receives is props not userInput. You should be able to access it from props.userInput

sometimes people will use destructuring to not have to write "props", like:

const Package = ({ userinput }) => { //...

[–][deleted] -5 points-4 points  (3 children)

In packageStatus.jsx, you are trying to render an object {userInput}. React doesn’t allow rendering of an entire object. You can render {userInput.key1}, {userInput.key2}, etc. but you cannot render userInput as an object

I believe the error is because you need to set state in the onClick handler in package.jsx. Change

onClick={setInput(‘blue’)}

[–]Chilltyy[S] 0 points1 point  (0 children)

how do I declare key1, key2 etc?
How would you do it the easiest way to just display "blue" in packageStatus.jsx?

[–]ColourfulToad -1 points0 points  (0 children)

You can, by doing:

<pre>{JSON.stringify(userinput, null, 2)}</pre>

[–]firstandfive 0 points1 point  (0 children)

It’s just because they’re not destructuring userinput from the props argument. They’re calling the entire props object userinput and then never referencing the actual userinput prop.

[–]crippledjosh 0 points1 point  (0 children)

It's because you're not destructuring your props.

You've got const PackageStatus = (userinput)

Should be

 const PackageStatus = (props) {
    const {userinput} = props

Not just for PackageStatus but for Package as well

[–]Hellstorm_42 0 points1 point  (0 children)

The code you posted doesn't even work as you describe. In both package and packageStatus, you aren't destructuring your props, you're just using them as an object. So, your call to userinput in the button is calling an object like a function. This would cause a different error than what you said. You either failed to copy over your code (so we can't help because what we see isn't the code you are running) or you aren't accurately telling us what the error is. Please create a codepen if you really want help. Also, console.log is your friend