Skip to content

Commit

Permalink
Batch event handling in React Native
Browse files Browse the repository at this point in the history
This fixes an issue where handling events on a node that was just removed threw a "All native instances should have a tag." error and matches what we do in the DOM renderer in ReactEventListener.
  • Loading branch information
sophiebits committed Apr 21, 2016
1 parent b7a2409 commit 9f11f8c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/renderers/native/ReactNative/ReactNativeEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var EventPluginRegistry = require('EventPluginRegistry');
var ReactEventEmitterMixin = require('ReactEventEmitterMixin');
var ReactNativeComponentTree = require('ReactNativeComponentTree');
var ReactNativeTagHandles = require('ReactNativeTagHandles');
var ReactUpdates = require('ReactUpdates');
var EventConstants = require('EventConstants');

var merge = require('merge');
Expand Down Expand Up @@ -119,12 +120,14 @@ var ReactNativeEventEmitter = merge(ReactEventEmitterMixin, {
) {
var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT;
var inst = ReactNativeComponentTree.getInstanceFromNode(rootNodeID);
ReactNativeEventEmitter.handleTopLevel(
topLevelType,
inst,
nativeEvent,
nativeEvent.target
);
ReactUpdates.batchedUpdates(function() {
ReactNativeEventEmitter.handleTopLevel(
topLevelType,
inst,
nativeEvent,
nativeEvent.target
);
});
},

/**
Expand Down

0 comments on commit 9f11f8c

Please sign in to comment.