1.0.5 • Published 2 years ago
async-button v1.0.5
async-button
Button with asynchronous onClick
Install
npm install --save async-button
yarn add async-button
Usage
import React, { Component } from "react";
import { AsyncButton } from "async-button";
export const callback = async (): Promise<void> => {
return new Promise<void>((resolve) => setTimeout(resolve, 4 * 1000));
};
class Example extends Component {
render() {
return (
<AsyncButton
// The asynchronous callback.
onClick={callback}
// (optional) Whether the onClick should be called automatically.
callOnMount={true}
// (optional) Disable the button after onClick has been succesfully called.
allowOnlyOnce={true}
/>
);
}
}