import React, { useState, Component } from 'react';
type CounterProps = {
initialValue: number;
};
function Counter(props: CounterProps) {
const [count, setCount] = useState(props.initialValue);
return (
<div>
<p>Current count is {count}</p>
<p>
<button
type="button"
onClick={e => {
e.preventDefault();
setCount(c => c + 1);
}}
>
Increase
</button>{' '}
<button
type="button"
onClick={e => {
e.preventDefault();
setCount(c => c - 1);
}}
>
Decrease
</button>
</p>
</div>
);
}
class App extends Component {
render() {
return <Counter initialValue={10} />;
}
}
export default App;