Skip to content

Instantly share code, notes, and snippets.

@tortillaj
Created January 18, 2018 19:49
Show Gist options
  • Save tortillaj/2a8f59d978e344017c714d280cd97895 to your computer and use it in GitHub Desktop.
Save tortillaj/2a8f59d978e344017c714d280cd97895 to your computer and use it in GitHub Desktop.
import {compose, setPropTypes, defaultProps} from 'recompose'
const enhance = compose(
setPropTypes({
onClick: PropTypes.func,
type: PropTypes.oneOf(['submit', 'button']),
className: PropTypes.func,
children: PropTypes.func.isRequired,
isLoading: PropTypes.bool,
}),
defaultProps({
type: 'button',
}),
)
const Button = ({ type, className, children, onClick, isLoading }) => {
return (
<button type={type} className={className} onClick={onClick}>
{isLoading && <Loading />}
{!isLoading && children}
</button>
)
}
export default enhance(Button)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment