react-standalone
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React Standalone</title>
</head>
<body>
<div id="root"></div>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<script type="text/babel" src="./main.js"></script>
</body>
</html>⏎
class App extends React.Component {
constructor() {
super()
this.state = {num: 1}
}
render() {
const {num} = this.state;
return (
<div>
<h1>up to: {num}</h1>
<div>
<button onClick={() => (this.setState({num: num + 1})) }>plus</button>
<button onClick={() => (this.setState({num: num - 1})) }>minus</button>
</div>
<div>
{
Array.from({length: num}, (v, k) => k + 1).map(n =>
<span key={n}>{n} </span>
)
}
</div>
</div>
)
}
}
ReactDOM.render(
<App/>,
document.getElementById('root')
);