JedWatson / react-tappable

Tappable component for React
http://jedwatson.github.io/react-tappable/
MIT License
863 stars 90 forks source link

Does it makes sense to use tappable to implement a button? #64

Closed 0x80 closed 7 years ago

0x80 commented 8 years ago

I was wondering if this makes any sense to you

     <Tappable
        className={buttonClasses}
        onFocus={::this.handleFocus}
        onBlur={::this.handleBlur}
        onMouseEnter={::this.handleMouseEnter}
        onMouseLeave={::this.handleMouseLeave}
        onTap={::this.handleTap}
        component={asLink ? 'a' : 'button' }
      >
        <span className={styles.content}>
          {label}
        </span>
      </Tappable>

I am basically trying to use the tappable behavior for links and buttons. The problem I'm facing here is that if I set a property like "disabled" on my component I somehow needs to be passed down to the Tappable component. So I'm starting to wonder if this even makes sense.

Should I just use react-tap-event-plugin + a regular link/button? Are there any traps I should be aware of if I do that? I thought react-tappable soved a few issues I would have to solve manually for iOS if I use regular buttons/links.

nmn commented 8 years ago

I did something like this for yarr.js You can take a look: https://github.com/nmn/yarr/blob/master/src/link.js

It doesn't have a disabled property, but that can easily be added. Long story short, this is totally doable, but you will need to do some manual work to hook stuff up correctly.