Created
January 18, 2018 19:49
-
-
Save tortillaj/2a8f59d978e344017c714d280cd97895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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