Last active
June 30, 2018 05:34
-
-
Save qwertie/36bda7e94c2be8651d504c4c00f7d09f to your computer and use it in GitHub Desktop.
Minimal React+TypeScript example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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