Tap events broken with ReactJS update in Chrome Mobile Emulator

I recently upgraded from React 0.10 to React 0.14. I initially received an error that React.initializeTouchEvents not a function. I read some documentation stating that the need for this initialization disappeared in the most recent version of React, so I ended it up. Now, however, no sensory events are logged in my project. What do I need to do to get them working again?

Below I have included some simple test code that I wrote to try to solve this problem. Currently, no sensory events are logged at all.

My main js file:

 /** @jsx React.DOM */ var React = require('react'); var ReactDOM = require('react-dom'); var TestButton = require('components/common/testButton'); try { var lander = (<TestButton/>); ReactDOM.render(lander, document.getElementById('myContainer')); } catch (e) { error.errorHandler(e); } 

My TestButton component:

 /** @jsx React.DOM */ var React = require('react'); var TestButton = React.createClass ({ getInitialState: function () { return { text: "Click Here!", }; }, toggle: function () { console.log('in toggle'); if (this.state.text == "Click Here!"){ this.setState({ text: "Good Job!", }); } else { this.setState({ text: "Click Here!", }); } }, render: function () { return ( <div onTouchEnd={this.toggle}> {this.state.text} </div> ); }, }); module.exports = TestButton; 

Any ideas would be greatly appreciated.

EDIT: I tried switching to onTouchEnd since onTouchTap is no longer available. However, I still have the same problem.

EDIT: This works great from the mobile device itself. However, I can’t get it to work with the Chrome mobile emulator

+6
source share
3 answers

As Mathletics says, onTouchTap not available as an event. However, you can give this plugin an attempt to simplify the task https://github.com/zilverline/react-tap-event-plugin

+2
source

TouchTap no longer available as an event. read documents on TouchEvents to select the appropriate event. You can bind:

 onTouchCancel onTouchEnd onTouchMove onTouchStart 
0
source

If you just want to capture the use of the onClick tap event. Events onTouchStart, onTouchEnd ect. are drag and drop events. For checks, you will need a third-party library, for example, reactive hammers.

0
source

All Articles