Created
October 12, 2018 22:11
-
-
Save bedorlan/5a05a10813f4d4da6ba54ee703b764f9 to your computer and use it in GitHub Desktop.
React starter
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
<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