React 16.4 removes a lot of internals (#121) this plugin depends on and will break the plugin.
Since the problem it solves has been fixed in most browsers by now you should migrate away from this plugin.
You've probably heard of iOS's dreaded 300ms tap delay. React's
onClick attribute falls prey to it.
Facebook's working on a solution in the form of
TapEventPlugin, but it won't be made available until 1.0.
If you're reading this, you're probably working on a project that can't wait until they figure out how they want to publish it. This repo is for you.
Facebook is not planning on supporting tap events (#436) because browsers are fixing/removing the click delay. Unfortunately it will take a lot of time before all mobile browsers (including iOS' UIWebView) will and can be updated.
Verify if you need this plugin for the browsers you need to support.
Compatible with React >= 16.0 && < 16.4:
$ npm i --save react-tap-event-plugin
Compatible with React >= 15.4 && < 16.0:
$ npm i --save email@example.com
Compatible with React > 0.14 && < 15.4:
$ npm i --save firstname.lastname@example.org
Compatible with React <= 0.14:
$ npm i --save email@example.com
var injectTapEventPlugin = ;;
See demo project for a complete working example.
var React = ;var ReactDOM = ;injectTapEventPlugin = ;;var Main = React;ReactDOM;
Ignoring ghost clicks
When a tap happens, the browser sends a
touchend, and then
300ms later, a
click event. This plugin ignores the click event if it has
been immediately preceeded by a touch event (within 750ms of the last touch
Occasionally, there may be times when the 750ms threshold is exceeded due to slow rendering or garbage collection, and this causes the dreaded ghost click.
The 750ms threshold is pretty good, but sometimes you might want to override
that behaviour. You can do this by supplying your own
function when you inject the plugin.
The following example will simply reject all click events, which you might
want to do if you are always using
onTouchTap and only building for touch
var React =injectTapEventPlugin = ;;
Build standalone version
Use the demo project and it's README instructions to build a version of React with the tap event plugin included.