An easy way to get started at CodePen with React 0.13 and ES6.
Created
June 19, 2019 19:36
-
-
Save b3b00/0012a39c4e0d40a0805cc486b06a79b7 to your computer and use it in GitHub Desktop.
React at CodePen
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
<div id="app"></app> |
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
class Button extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
count: 0, | |
}; | |
} | |
updateCount() { | |
this.setState((prevState, props) => { | |
return { count: prevState.count + 1 } | |
}); | |
} | |
render() { | |
return (<button | |
onClick={() => this.updateCount()} | |
> | |
Clicked {this.state.count} times | |
</button>); | |
} | |
} | |
React.render(<Button />, document.getElementById('app')); |
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
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.min.js"></script> |
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
html, body | |
height: 100% | |
body | |
background: #333 | |
display: flex | |
justify-content: center | |
align-items: center | |
font-family: Helvetica Neue | |
h1 | |
font-size: 2em | |
color: #eee | |
display: inline-block | |
a | |
color: white | |
p | |
margin-top: 1em | |
text-align: center | |
color: #aaa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment