0.2.0 • Published 7 years ago

react-async-button v0.2.0

Weekly downloads
715
License
MIT
Repository
github
Last release
7 years ago

react-async-button

React button component for handling async actions. Inspired from ember-async-button

npm version Build Status Coverage Status

Installation

$ npm install react-async-button --save

DOCS & DEMO

https://selvagsz.github.io/react-async-button/

Example

import React from 'react';
import { render } from 'react-dom';
import AsyncButton from 'react-async-button';

export default App extends Component {
  clickHandler() {
    return new Promise((resolve, reject) => {
      // some async stuff
      setTimeout(resolve, 500);
    })
  }

  render() {
    return (
      <AsyncButton
        className="btn"
        text="Save"
        pendingText="Saving..."
        fulFilledText="Saved Successfully!"
        rejectedText="Failed! Try Again"
        loadingClass="isSaving"
        fulFilledClass="btn-primary"
        rejectedClass="btn-danger"
        onClick={this.clickHandler}
       />
    )
  }
}

render(<App/>, document.getElementById('root'));

Note clickHandler should return a promise for the pending state

0.2.0

7 years ago

0.1.0

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago