Files
frontend-bootcamp/docs/step1-04/src/components/Counter.tsx
2019-02-19 23:41:11 -08:00

26 lines
493 B
TypeScript

import React from 'react';
import { Button } from './Button';
export class Counter extends React.Component<any, any> {
constructor(props) {
super(props);
this.state = {
counter: props.start
};
}
render() {
return (
<div>
<span> {this.state.counter} </span>
<Button
onClick={() => {
this.setState({ counter: this.state.counter + 1 });
}}
>
Click Me
</Button>
</div>
);
}
}