Skip to content

Commit 39e4a45

Browse files
authored
Fix #26
Avoid crashing the app when the event is called while the react context is not initialized.
1 parent 1933faf commit 39e4a45

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,10 @@ private String getHeaderIgnoreCases(HashMap<String,String> headers, String field
727727
}
728728

729729
private void emitStateEvent(WritableMap args) {
730-
RNFetchBlob.RCTContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
731-
.emit(RNFetchBlobConst.EVENT_HTTP_STATE, args);
730+
if (RNFetchBlob.RCTContext.hasActiveCatalystInstance()) {
731+
RNFetchBlob.RCTContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
732+
.emit(RNFetchBlobConst.EVENT_HTTP_STATE, args);
733+
}
732734
}
733735

734736
@Override

0 commit comments

Comments
 (0)