Created
November 20, 2015 09:08
-
-
Save peterlazar1993/87e6d4fc199e560cc686 to your computer and use it in GitHub Desktop.
React HelloWOrld with state
This file contains hidden or 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
class HelloWorld extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {clicks: 0}; | |
} | |
render() { | |
return ( | |
<div> | |
Hello, World! I am {this.props.name} | |
<span> | |
+{this.state.clicks} | |
</span> | |
</div> | |
); | |
} | |
}; | |
React.render(<HelloWorld name="React"/>, document.getElementById('container-1')); | |
React.render(<HelloWorld name="React Native"/>, document.getElementById('container-2')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment