@samitouri / QOS-React / commits / 69b6869a3e

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.

Sebastian Markbåge committed Apr 23, 2016 at 13:10 UTC 69b6869a3e6861b325ca2e9bb2d938cb81c7a090
1 file changed +5
src/renderers/native/ReactNative/ReactNativeEventEmitter.js
+5
@@ -120,6 +120,11 @@ var ReactNativeEventEmitter = merge(ReactEventEmitterMixin, {
120 ) {
121 var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT;
122 var inst = ReactNativeComponentTree.getInstanceFromNode(rootNodeID);
123 + if (!inst) {
124 + // If the original instance is already gone, we don't have to dispatch
125 + // any events.
126 + return;
127 + }
128 ReactUpdates.batchedUpdates(function() {
129 ReactNativeEventEmitter.handleTopLevel(
130 topLevelType,