Files
JavaScriptServices/templates/ReactSpa/ClientApp/components/Counter.tsx
2016-02-24 18:37:47 +00:00

31 lines
722 B
TypeScript

import * as React from 'react';
interface CounterState {
currentCount: number;
}
export class Counter extends React.Component<any, CounterState> {
constructor() {
super();
this.state = { currentCount: 0 };
}
public render() {
return <div>
<h1>Counter</h1>
<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
});
}
}