mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
31 lines
723 B
TypeScript
31 lines
723 B
TypeScript
import * as React from 'react';
|
|
|
|
interface CounterState {
|
|
currentCount: number;
|
|
}
|
|
|
|
export class Counter extends React.Component<void, CounterState> {
|
|
constructor() {
|
|
super();
|
|
this.state = { currentCount: 0 };
|
|
}
|
|
|
|
public render() {
|
|
return <div>
|
|
<h2>Counter</h2>
|
|
|
|
<p>This is a simple example of a React component.</p>
|
|
|
|
<p>Current count: <strong>{ this.state.currentCount }</strong></p>
|
|
|
|
<button onClick={ () => { this.incrementCounter() } }>Increment</button>
|
|
</div>;
|
|
}
|
|
|
|
incrementCounter() {
|
|
this.setState({
|
|
currentCount: this.state.currentCount + 1
|
|
});
|
|
}
|
|
}
|