Skip to content

Instantly share code, notes, and snippets.

@qwertie
Last active June 30, 2018 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwertie/36bda7e94c2be8651d504c4c00f7d09f to your computer and use it in GitHub Desktop.
Save qwertie/36bda7e94c2be8651d504c4c00f7d09f to your computer and use it in GitHub Desktop.
Minimal React+TypeScript example
import * as React from 'react';
import * as ReactDOM from 'react-dom';
class App extends React.Component<{greeting: string}, {count:number}> {
state = {count: 0};
render() {
return (
<div>
<h2>{this.props.greeting}</h2>
<button onClick={() => this.setState(
{count: this.state.count+1})}>
This button has been clicked {this.state.count} times.
</button>
</div>);
}
}
ReactDOM.render(
<App greeting="Hello, world!"/>,
document.getElementById('app')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment