import React, { PropTypes } from 'react';

export default React.createClass({
  propTypes: {
    disabled: PropTypes.bool,
    text: PropTypes.string,
    pendingText: PropTypes.string,
    fulFilledText: PropTypes.string,
    rejectedText: PropTypes.string,
    onClick: PropTypes.func,
  },

  getInitialState() {
    return {
      pending: false,
      promiseFulfilled: false,
      promiseRejected: false,
    };
  },

  resetState() {
    this.setState({
      pending: false,
      promiseFulfilled: false,
      promiseRejected: false,
    });
  },

  handleClick(...args) {
    this.setState({
      pending: true,
    });

    const promise = this.props.onClick(args);
    if (promise && promise.then) {
      promise.then(() => {
        this.setState({
          pending: false,
          promiseRejected: false,
          promiseFulfilled: true,
        });
      }).catch((error) => {
        this.setState({
          pending: false,
          promiseRejected: true,
          promiseFulfilled: false,
        });
        throw error;
      });
    } else {
      this.resetState();
    }
  },

  render() {
    const isPending = this.state.pending;
    const isFulfilled = this.state.promiseFulfilled;
    const isRejected = this.state.promiseRejected;
    const isDisabled = this.props.disabled || isPending;
    let buttonText;

    if (isPending) {
      buttonText = this.props.pendingText;
    } else if (isFulfilled) {
      buttonText = this.props.fulFilledText;
    } else if (isRejected) {
      buttonText = this.props.rejectedText;
    }
    buttonText = buttonText || this.props.text;

    return (
      <button {...this.props} disabled={isDisabled} onClick={this.handleClick}>
        {buttonText}
      </button>
		);
  },
});

@@ -55,276 +55,109 @@
 ult 
-React.createClass(%7B%0A  propTypes: %7B%0A    disabled: PropTypes.bool,%0A    text: PropTypes.string,%0A    pendingText: PropTypes.string,%0A    fulFilledText: PropTypes.string,%0A    rejectedText: PropTypes.string,%0A    onClick: PropTypes.func,%0A  %7D,%0A%0A  getInitialState() %7B%0A    return
+class AsyncButton extends React.Component %7B%0A  constructor(props) %7B%0A    super(props);%0A    this.state =
  %7B%0A 
@@ -244,25 +244,24 @@
 ,%0A    %7D;%0A  %7D
-,
 %0A%0A  resetSta
@@ -377,25 +377,24 @@
 %0A    %7D);%0A  %7D
-,
 %0A%0A  handleCl
@@ -932,17 +932,16 @@
    %7D%0A  %7D
-,
 %0A%0A  rend
@@ -1512,16 +1512,22 @@
 nClick=%7B
+() =%3E 
 this.han
@@ -1534,16 +1534,18 @@
 dleClick
+()
 %7D%3E%0A     
@@ -1588,10 +1588,220 @@
 %0A  %7D
+%0A%7D%0A%0AAsyncButton.propTypes = %7B%0A  disabled: PropTypes.bool,%0A  text: PropTypes.string,%0A  pendingText: PropTypes.string,%0A  fulFilledText: PropTypes.string,%0A  rejectedText: PropTypes.string,%0A  onClick: PropTypes.func
 ,%0A%7D
-)
 ;%0A

Use ES6 class syntax