Question: onTap vs onClick. How to support both correctly?
See original GitHub issueHello
It seems that mobile browsers are able to handle click events. (However, iOS does some strange things see https://github.com/facebook/react/issues/2055)
So what I don’t understand is what’s the advantage of tap over click exactly?
In an application that should handle both mouse and touch events (responsive websites, or websites for laptops with touch screens), what should I do? use both onClick
and onTap
at the same time?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
React onClick and onTouchStart fired simultaneously
Solved this problem using similar events between touch and mouse. touchStart/mouseDown or touchEnd/mouseUp. It fires one or another, ...
Read more >SyntheticEvent - React
This reference guide documents the SyntheticEvent wrapper that forms part of React's Event System. See the Handling Events guide to learn more.
Read more >Touch events - Web APIs - MDN Web Docs - Mozilla
To provide quality support for touch-based user interfaces, touch events offer the ability to interpret finger (or stylus) activity on touch ...
Read more >Introduction to browser events - The Modern JavaScript Tutorial
Let's say, one part of our code wants to highlight a button on click, and another one wants to show a message on...
Read more >rest return array
My problem relates to a service that returns its items as an array ... fun() with five arguments and the first two were...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just use
onTap
, you don’t needonClick
at all@dcousens there are cases where you may want to differentiate between a click and a tap and not always handle the 2 the same way.
However I think the easiest would probably be to check the event type my callback receive on such case, so I can be fine if the lib triggers onTap for both events