JSFiddle - React, Tailwind, and code Playground

by pleinx

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="myapp"></div>

Babel + JSX

class MyApp extends React.Component {
	constructor() {
  	super();
    
    this.state = {
    	disable: false
    };
  }

	render() {
  	let opts = {};
  
  	if(this.state.disable) {
    	opts = {disabled: 'disabled'};
    }
  
		return (
    	<div>
    	  <h1>A awesome headline</h1>
        <div>
          <button {...opts} onClick={this.onButtonClick.bind(this)}>Add to Cart</button>
        </div>
    	</div>
    );
  }
  
  onButtonClick() {
  	this.setState({disable: true});
  }
}

ReactDOM.render(
  <MyApp/>,
  document.getElementById('myapp')
);