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
const FirstImage = () => <div><img
src="https://www.import.io/wp-content/uploads/2017/10/React-logo-1.png" crossOrigin="anonymous"/></div>
const SecondImage = () => <div><img
src="https://www.import.io/wp-content/uploads/2017/10/React-logo-1.png" crossOrigin="anonymous"/></div>
class Hello extends React.Component {
state={secondImage: false}
changeImage = () => {
this.setState({secondImage: !this.state.secondImage})
}
render() {
return <div><button onClick={this.changeImage}>Reload</button> {!this.state.secondImage ? <FirstImage/> : <SecondImage></SecondImage>}</div>;
}
}
ReactDOM.render(
<Hello name="World" />,
document.getElementById('container')
);