import React, { useState, useReducer } from 'react';
import ReactDOM from 'react-dom';
const App = () => {
const [count, setCount] = useState(0)
const add = () => {
setCount(count + 1)
}
const subtract = () => {
if (count > 0) {
setCount(count - 1)
}
}
return (
<section>
<h2>Counter: The Most Novel Example I Could Come Up With</h2>
<div className="counter">
<button onClick={subtract}>-</button>
<input
type="text"
aria-label="count"
defaultValue={count}
/>
<button onClick={add}>+</button>
</div>
</section>
)
}
ReactDOM.render(<App />, document.getElementById('root'));