JedWatson / react-tappable

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

Expose the functionality as a Mixin #7

Closed ibirrer closed 9 years ago

ibirrer commented 9 years ago

I wanted to be able to use your Tappable component for a link tag (a). Unfortunately, the current implementation did not allow me to add arbitrary attributes like id or href (unless I overlooked sth.). Therefore I tried to refactor the code such that it is also available as a mixin. A component using the mixin would look sth. like the following:

var React = require('react');
var Tappable = require('react-tappable');

var TouchLink = React.createClass({
  mixins: [Tappable.Mixin],
  render: function() {
    return (
      <a id="foo" href="http://www.google.ch" style={this.touchStyles()} {...this.handlers()}>Link</a>
    );
  }
});
module.exports = TouchLink;

The functionality of the original component should still be the same (the example still working without changes).

What do you think?

JedWatson commented 9 years ago

Looks great, thanks @ibirrer!

Will test & release shortly.