mirror of
https://github.com/10h30/fullstackopen.git
synced 2026-06-05 15:08:33 +09:00
23 lines
614 B
JavaScript
23 lines
614 B
JavaScript
import React, { 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>Statistic</h1>
|
|
<p>Good: {good}</p>
|
|
<p>Neutral: {neutral}</p>
|
|
<p>Bad: {bad}</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default App |