Home > Mobile >  React onMouse doesnt fire on iOS devices
React onMouse doesnt fire on iOS devices

Time:02-05

I've built a React app which works fine in the computer, but the button won't fire on my iOS phone.

I've tried adding the cursor:'pointer' like that:

<button onClick={() => setdata((previous) => !previous)} type="button" style={{ cursor: 'pointer' }}>Start</button>

I've also added it in the .css of the button. (in all 3 widths I'm using, for mobile/tablet/pc)

Tried onm ouseClick / onClick / etc.. doesn't help.

Any ideas?

CodePudding user response:

You've tried onMouseDown?

<button 
 onm ouseDown={() => setdata((previous) => !previous)} 
 type="button" 
 style={{ cursor: 'pointer' }}
>
 Start
</button>

source: https://stackoverflow.com/a/37273344/19503616

CodePudding user response:

It's possible that the issue might be with the type of the button or with the way the event handler is being attached to the button. Try changing the type of the button from "button" to "submit". Also, make sure that the onClick event handler is correctly attached to the button component. Here's how it should look:

<button type="submit" onClick={() => setdata((previous) => !previous)} style={{ cursor: 'pointer' }}>Start</button>

If the above does not work, try debugging the issue by using console.log statements within the event handler to check if it's being called.

  • Related