React Base Fiddle (JSX)
Starting point for creating JSFiddles with React.
HTML
<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>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
Babel + JSX
class Names {
constructor (names) {
this.names = names;
}
contains (names) {
console.log(this);
}
}
class Hello extends React.Component {
constructor(props) {
super(props);
this.namesInstance = new Names(["Madrid", "Paris"]);
}
handleClick = () => {
this.namesInstance.contains(["Madrid"]);
}
render() {
return <div onClick={this.handleClick}>Hello {this.props.name}</div>;
}
}
ReactDOM.render(
<Hello name="World" />,
document.getElementById('container')
);