diff --git a/part1/src/App.js b/part1/src/App.js index edc4436..ea413aa 100644 --- a/part1/src/App.js +++ b/part1/src/App.js @@ -1,46 +1,50 @@ import { useState } from 'react' -const Display = ({ counter }) => { +const Stats = ({ positive, neutral, negative }) => { return ( -
{counter}
+ <> +

Results

+

Positive: {positive}

+

Neutral: {neutral}

+

Negative: {negative}

+ ) } -const Button = ({ handleClick, text }) => { +const Button = ({ handler, text }) => { return ( - ) } const App = () => { - const [counter, setCounter] = useState(0) - console.log('rendering with counter value', counter) - const increaseByOne = () => { - console.log('increasing, value before', counter) - setCounter(counter + 1) + const [good, setGood] = useState(0) + const [neutral, setNeutral] = useState(0) + const [bad, setBad] = useState(0) + + const incPositive = () => { + setGood(good + 1) } - const decreaseByOne = () => { - console.log('decreasing, value before', counter) - setCounter(counter - 1) + const incNegative = () => { + setBad(bad + 1) } - const setToZero = () => { - console.log('resetting to zero, value before', counter) - setCounter(0) + const incNeutral = () => { + setNeutral(neutral + 1) } return (
- -
) - } export default App