Last active
July 19, 2018 06:23
-
-
Save inawrath/93a92ae8812eea50bb3d92a00e26fe9c to your computer and use it in GitHub Desktop.
Example ReactJS
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNext Bin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
<link href="https://fonts.googleapis.com/css?family=Glass+Antiqua" rel="stylesheet" type="text/css"> | |
<!-- CSS Reset --> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css"> | |
<!-- Milligram CSS minified --> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.1.0/milligram.min.css"> | |
<style> | |
body { | |
color: white; | |
background-color: #575A65; | |
font-family: 'Glass Antiqua', cursive; | |
} | |
#app { | |
padding: 20px; | |
text-align: center; | |
} | |
.name { | |
font-size: 1.7em; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="app"></div> | |
</body> | |
</html> |
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 {random} from 'starwars-names' | |
import React, { Component } from 'react' | |
import ReactDOM from 'react-dom' | |
class App extends Component { | |
state = { | |
name: '[Click the button]' | |
} | |
getRandomName = () => { | |
this.setState({name: random()}) | |
} | |
render() { | |
return ( | |
<div> | |
<h1>Random Star Wars Names</h1> | |
<div className="name">{this.state.name}</div> | |
<hr /> | |
<button onClick={this.getRandomName}> | |
New Random Name | |
</button> | |
</div> | |
) | |
} | |
} | |
ReactDOM.render( | |
<App />, | |
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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"starwars-names": "1.5.3", | |
"react": "15.6.2", | |
"react-dom": "15.6.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment