in my app.js
in const APP
i am returning
<Display results = {(good,neutral,bad)}></Display>
which are all numbers
in my display component which i have as this
const Display = ({good,neutral,bad}) => (
the parameters becomes undefined, or any. how come the numbers are not being passed.
full code
import { useState } from 'react'
const App = () => {
// save clicks of each button to its own state
const [good, setGood] = useState(0)
const [neutral, setNeutral] = useState(0)
const [bad, setBad] = useState(0)
return (
<div>
<h1>give feedback</h1>
<button onClick={() => setGood(good +1)}>Good </button>
<button onClick={() => setNeutral(neutral +1)}>Neutral</button>
<button onClick={() => setBad(bad +1)}>Bad</button>
<h1>Statistics</h1>
<Display results = {(good,neutral,bad)}></Display>
<h1>{good}{ neutral} {bad}</h1>
</div>
)
}
const Display = ({good,neutral,bad}) => (
console.log(good),
<table>
<tr>
<td>good</td>
<td>{good}</td>
</tr>
<tr>
<td>neutral</td>
<td>{neutral}</td>
</tr>
<tr>
<td>bad</td>
<td>{bad}</td>
</tr>
<tr>
<td>all</td>
<td>{good+neutral+bad}</td>
</tr>
<tr>
<td>average</td>
<td>{(good-bad)/(good+neutral+bad)}</td>
</tr>
<tr>
<td>positive</td>
<td>{(good)/(good+neutral+bad)}</td>
</tr>
</table>
)
export default App