React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://npmcdn.com/react@latest/dist/react-with-addons.js"></script>
<script src="https://npmcdn.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
class HelloWidget extends React.Component {
constructor(props) {
super(props);
this.names_holder = [];
this.state = {
name: []
};
}
handleClick = () => { //error here
let random = this.names_holder.concat(Math.ceil(Math.random() * 10) + 3);
this.setState({
name: random
});
}
render() {
return <div className = "widget" >
< button onClick = {
this.handleClick
} > Random concat < /button> {
JSON.stringify(this.state.name)
} < /div>;
}
ReactDOM.render( < HelloWidget name = "World" / > ,
document.getElementById('container')
);
}