Skip to content

Instantly share code, notes, and snippets.

@inawrath
Last active July 19, 2018 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inawrath/93a92ae8812eea50bb3d92a00e26fe9c to your computer and use it in GitHub Desktop.
Save inawrath/93a92ae8812eea50bb3d92a00e26fe9c to your computer and use it in GitHub Desktop.
Example ReactJS
<!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>
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'),
)
{
"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