Skip to content

Commit 1d05530

Browse files
CNDWjhen0409
authored andcommitted
set global.Blob to global.originalBlob before deleting global.Blob for rn > 0.54 compatability (#246)
1 parent 04db26a commit 1d05530

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

app/worker/setup.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ self.global = self;
1212
* it will used for `whatwg-fetch` on older RN versions
1313
*/
1414
if (self.Blob && self.Blob.toString() === 'function Blob() { [native code] }') {
15+
/*
16+
* RN > 0.54 will polyfill Blob.
17+
* If it is deleted before the RN setup, RN will not add a reference to the original.
18+
* We will need to be able to restore the original when running RN > 0.54 for networking tools,
19+
* so add the reference here as react-native will not do it if the original is deleted
20+
*/
21+
self.originalBlob = self.Blob;
1522
delete self.Blob;
1623
}
1724

docs/network-inspect-of-chrome-devtools.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ global.XMLHttpRequest = global.originalXMLHttpRequest ?
1515
global.FormData = global.originalFormData ?
1616
global.originalFormData :
1717
global.FormData;
18+
global.Blob = global.originalBlob ?
19+
global.originalBlob :
20+
global.Blob;
21+
global.FileReader = global.originalFileReader ?
22+
global.originalFileReader :
23+
global.FileReader;
1824
```
1925

2026
This allows you can open the `Network` tab in devtools to inspect requests of `fetch` and `XMLHttpRequest`.

0 commit comments

Comments
 (0)