Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import {compose, setPropTypes, defaultProps, withHandlers} from 'recompose'
const enhance = compose(
onClick: PropTypes.func,
type: PropTypes.oneOf(['submit', 'button']),
className: PropTypes.func,
children: PropTypes.func.isRequired,
isLoading: PropTypes.bool,
type: 'button',
onClick: props => e => {
// first do something other than what was passed
// if an onClick method was passed, do it
props.onClick && props.onClick(e)
onHover: props => e => {
// this function was not originally passed as a prop;
// it was created here. when recompose did it's magic,
// the component had it available as a prop!
const Button = ({ type, className, children, onClick, isLoading, onHover }) => {
return (
<button type={type} className={className} onClick={onClick} onMouseMove={onHover}>
{isLoading && <Loading />}
{!isLoading && children}
export default enhance(Button)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment