question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Can't find variable: self

See original GitHub issue

Hello.

I am using redux-api-middleware which is using version 2.2.1 of isomorphic-fetch. I am experiencing an error where self is undefined in React Native, which is a problem with this version of isomorphic-fetch. Most issues I have seen regarding this issue have been closed, but I feel that this is a fairly common issue and I have not been able to find a good solution. I’d love to work together, with a maintainer or anyone else having this problem, to solve it.

Thank you for reading and for your work on this library.

The error seems to be coming from this file:

image

Here is the stack trace:

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:25
  • Comments:6

github_iconTop GitHub Comments

26reactions
karimmortacommented, Jun 23, 2017

Here is a fix I use :

require('whatwg-fetch');
// module.exports = self.fetch.bind(self);
var globalObject = typeof self === "undefined" ? global : self;
module.exports = globalObject.fetch.bind(globalObject);

10reactions
lquixadacommented, Oct 6, 2017

For all those seeking for an isomorphic-fetch with React Native support alternative, see cross-fetch. It is updated and also brings optional polyfill.

graphql-request and VulcanJS are already using it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Error - Can't find variable: self - Stack Overflow
After adding a node module, isomorphic-fetch (version : ^2.2.1) in React Native app, I am getting an error of Can't find variable: self...
Read more >
Can't find variable: self when using datocms-client with react ...
Hi, I'm trying out DatoCMS with a react native app, but when I try to import anything from datocms-client (e.g. { SiteClient })...
Read more >
[Solved]-React Native Error - Can't find variable - appsloveworld
Coding example for the question React Native Error - Can't find variable: self-React Native.
Read more >
ReferenceError: Can't find variable: process - ServiceNow
The java console reports "ReferenceError: Can't find variable: process". Pushing the component to my dev instance the component works fine.
Read more >
Node.js – React Native Error – Can't find variable: self - iTecNote
After adding a node module, isomorphic-fetch (version : ^2.2.1) in React Native app, I am getting an error of Can't find variable: self...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found