Skip to content

Instantly share code, notes, and snippets.

@bedorlan
Created October 12, 2018 22:11
Show Gist options
  • Save bedorlan/5a05a10813f4d4da6ba54ee703b764f9 to your computer and use it in GitHub Desktop.
Save bedorlan/5a05a10813f4d4da6ba54ee703b764f9 to your computer and use it in GitHub Desktop.
React starter
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
class MyComponent extends React.Component {
constructor(props) {
super(props)
this.state = {i: 0}
}
componentWillMount() {
setInterval(() => {
this.setState({i: this.state.i + 1})
}, 1000)
}
render() {
return <div>
<Counter count={this.state.i} />
</div>
}
}
function Counter(props) {
return <div>count={props.count}</div>
}
ReactDOM.render(
<MyComponent />,
document.getElementById('root')
)
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment