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.

[JS] Expose global as `self` too

See original GitHub issue

In JavascriptCore self is not defined. Libraries like bluebird for example rely on self being the global object instead of window, as it works in web workers too.

This fails in react-native due to self not being defined. A simple global.self = global at the beginning of the script solves this issue. Could we get this into the default packaged code so that we don’t have to put the statement in there by ourselves?

Edit: As discussed in https://github.com/petkaantonov/bluebird/issues/630

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

0reactions
johanneslumpecommented, May 30, 2015

Published as react-native-browser-polyfill!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid global variables in JavaScript? - Stack Overflow
The easiest way is to wrap your code in a closure and manually expose only those variables you need globally to the global...
Read more >
JavaScript: Correct way to define global variables
Correct way to declare global variable in JavaScript ... The proper way is to use window object. And use the syntax like this:...
Read more >
Avoiding mutable global state in browser JS | by Josh Wulf
Global scope is a feature of browser JavaScript that is a source of application-spanning bugs (it is global). Global state doesn't just ...
Read more >
The JavaScript Global Object Variable — When Should We ...
The global object is always in the topmost scope. There's nothing else above it. Therefore, it can be accessed by anything. Consider the...
Read more >
JavaScript Global Object | Contentful
Thinking of front-end code, it's clear that additional global variables do have a strong use case. Libraries like jQuery place themselves in the ......
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