Ignore events fired on missing React Native instances

This can happen if something gets unmounted before the event gets
dispatched. I'm not sure how this works out exactly but this
preserves previous behavior in this scenario.
This commit is contained in:
Sebastian Markbåge
2016-04-23 13:10:00 -07:00
parent 2f2ed71bd0
commit 69b6869a3e
@@ -120,6 +120,11 @@ var ReactNativeEventEmitter = merge(ReactEventEmitterMixin, {
) {
var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT;
var inst = ReactNativeComponentTree.getInstanceFromNode(rootNodeID);
if (!inst) {
// If the original instance is already gone, we don't have to dispatch
// any events.
return;
}
ReactUpdates.batchedUpdates(function() {
ReactNativeEventEmitter.handleTopLevel(
topLevelType,