Skip to content

Instantly share code, notes, and snippets.

@malerba118
Last active November 21, 2018 04:08
Show Gist options
  • Select an option

  • Save malerba118/86465f12da532d57f32d607e90f9d72b to your computer and use it in GitHub Desktop.

Select an option

Save malerba118/86465f12da532d57f32d607e90f9d72b to your computer and use it in GitHub Desktop.
import React from "react"
import PropTypes from 'prop-types'
import { PromiseButtonBase } from 'components/Universal'
import { PulseLoader } from 'react-spinners'
class PromiseButton extends React.Component {
render() {
const {
children,
...other
} = this.props
return (
<PromiseButtonBase
{...other}
disableOnPending
renderOnPending={() => (
<PulseLoader color="teal"/>
)}
renderOnFulfilled={() => children}
renderOnRejected={() => children}
>
{children}
</PromiseButtonBase>
)
}
}
PromiseButton.propTypes = {
onClick: PropTypes.func
}
PromiseButton.defaultProps = {
onClick: () => {}
}
export default PromiseButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment