Skip to content

Commit 8488358

Browse files
committed
wrap RCTDeviceEventEmitter.emit in hasActiveReactInstance check
1 parent a77445a commit 8488358

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/react-native-performance/android/src/main/java/com/oblador/performance/PerformanceModule.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private void emit(PerformanceMetric metric) {
187187
WritableMap map = Arguments.fromBundle(metric.getDetail());
188188
params.putMap("detail", map);
189189
}
190-
if (getReactApplicationContext().hasActiveCatalystInstance()) {
190+
if (getReactApplicationContext().hasActiveReactInstance()) {
191191
getReactApplicationContext()
192192
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
193193
.emit("metric", params);
@@ -202,9 +202,11 @@ private void emit(PerformanceMark mark) {
202202
WritableMap map = Arguments.fromBundle(mark.getDetail());
203203
params.putMap("detail", map);
204204
}
205-
getReactApplicationContext()
206-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
207-
.emit("mark", params);
205+
if (getReactApplicationContext().hasActiveReactInstance()) {
206+
getReactApplicationContext()
207+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
208+
.emit("mark", params);
209+
}
208210
}
209211

210212
@Override
@@ -222,6 +224,6 @@ public void onCatalystInstanceDestroy() {
222224

223225
// Fix new arch runtime error
224226
public void addListener(String eventName) {
225-
227+
226228
}
227229
}

0 commit comments

Comments
 (0)