mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
26 lines
493 B
TypeScript
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>
|
|
);
|
|
}
|
|
}
|