Skip to content

Commit

Permalink
Ignore events fired on missing React Native instances
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage committed Apr 23, 2016
1 parent 2f2ed71 commit 69b6869
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/renderers/native/ReactNative/ReactNativeEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 69b6869

Please sign in to comment.