react-native: Nested React Native projects result in TypeError: undefined is not an object (evaluating self.fetch)
I’m unsure how related this is to #5667 or #3975 but I’ve been trying to figure this out for 5 hours.
Here’s the repo: https://github.com/bloveit/react-native-redux-navigation
I’m trying to create a React Native example for this module but there is an error that occurs when trying to run the example.
To reproduce:
git clone https://github.com/bloveit/react-native-redux-navigation.git
cd react-native-redux-navigation
npm i
cd examples/TabsExample
npm i
react-native run-ios
I tried to pinpoint the error to a specific package, but no luck. I also tried nesting other React Native projects but the bug didn’t happen (it seems to be an edge case).
Would greatly appreciate some insight on this bug!
Screenshot:
Thanks! 🍺
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 18 (3 by maintainers)
Commits related to this issue
- fix(HttpSeervice): self.fetch did not exist wtf? see: https://github.com/facebook/react-native/issues/9599 — committed to davidvuong/ddfa-rn-app by davidvuong 7 years ago
- Fix for RN issue 9599 (self.fetch is undefined) — committed to LoicVerrall/mobile by LoicVerrall 6 years ago
@migueloller Hey I got it working using RN 0.33 and doing a hack - following this project:
https://github.com/johanneslumpe/react-native-browser-polyfill
Specifically, I added the following to my app.js:
global.self = global;
I added it right at the top. Now my fetches are working properly again. Seems like a dirty hack but I was a bit desperate to get it going on iOS10 and now it’s running again.
Actually I had to do this:
because when debuging remotely I was getting: “cannot assign to read only property ‘self’ of object '#<DedicatedWorkerGlobalScope>?”
I also have this issue all of a sudden. I have tried the global.self = global; fix to no avail. Running RN0.54
This issue has reappeared for me when upgrading from RN0.51 to RN0.53 The workaround in this commit: https://github.com/davidvuong/ddfa-rn-app/commit/e54a799a92d28a894b7c1ad6d2e3efc727922069
makes the problem go away
A most peculiar thing is that if remote JS debugging is turned on, the error goes away.