Skip to content

Commit 98746a9

Browse files
authored
fix(android): crash when library try to access JSModule before it is initialized (oblador#107)
Co-authored-by: Harsh Singhal <hsnghal@amazon.com>
1 parent 48a0470 commit 98746a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ private void emit(PerformanceMetric metric) {
187187
WritableMap map = Arguments.fromBundle(metric.getDetail());
188188
params.putMap("detail", map);
189189
}
190-
getReactApplicationContext()
191-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
192-
.emit("metric", params);
190+
if (getReactApplicationContext().hasActiveCatalystInstance()) {
191+
getReactApplicationContext()
192+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
193+
.emit("metric", params);
194+
}
193195
}
194196

195197
private void emit(PerformanceMark mark) {

0 commit comments

Comments
 (0)