Update EventEmitter.js (#23047)
Summary: added protection for emit() because subscription.listener may have been removed during event loop Changelog: ---------- [GENERAL][FIX] Avoid crash when subscription listener may have been removed during event loop Pull Request resolved: https://github.com/facebook/react-native/pull/23047 Differential Revision: D13761725 Pulled By: cpojer fbshipit-source-id: 0753b780067bd712cd43caf63020c3f0d6ea9f52
This commit is contained in:
parent
ec488dcf63
commit
47e77682d4
|
@ -176,7 +176,7 @@ class EventEmitter {
|
||||||
const subscription = subscriptions[i];
|
const subscription = subscriptions[i];
|
||||||
|
|
||||||
// The subscription may have been removed during this event loop.
|
// The subscription may have been removed during this event loop.
|
||||||
if (subscription) {
|
if (subscription && subscription.listener) {
|
||||||
this._currentSubscription = subscription;
|
this._currentSubscription = subscription;
|
||||||
subscription.listener.apply(
|
subscription.listener.apply(
|
||||||
subscription.context,
|
subscription.context,
|
||||||
|
|
Loading…
Reference in New Issue