ES2015 React Component

by Owain Stratton

HTML

<script src="https://unpkg.com/react@0.14.0/dist/react-with-addons.js"></script>
<script src="https://unpkg.com/react-dom@0.14.0/dist/react-dom.js"></script>
<div id="app">
	<!-- This element's contents will be replaced with your component. -->
</div>

Babel + JSX

class MyComponent extends React.Component {
	constructor(props) {
		super(props);
		console.log(props);
		this.state = {
			firstName: 'John'
		}
	}
	
	render() {
		return (
			<p>{this.state.firstName} {this.props.lastName}</p>
		);
	}
}


ReactDOM.render(<MyComponent lastName='Doe' />, document.getElementById("app"));