question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: onTap vs onClick. How to support both correctly?

See original GitHub issue

Hello

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:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
dcousenscommented, Jan 11, 2017

Just use onTap, you don’t need onClick at all

2reactions
slorbercommented, Jan 12, 2017

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found