An easy way to get started at CodePen with React 0.13 and ES6.
Created
January 7, 2024 03:32
-
-
Save fdciabdul/8e8ae8f5e46e42a44df0df401851e4b9 to your computer and use it in GitHub Desktop.
React at CodePen
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
| <div id="app"></app> |
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 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 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
| <script src="//cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.min.js"></script> |
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
| 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