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.

"Can't find variable: document" React Native error (3.3.0-alpha.2)

See original GitHub issue

Hello,

I am trying to get 3.3 up & running so that I can have accessibility labels (#1780) for Detox testing. Everything installs fine, but when I start up the app, I get a RSOD on Can't find variable: document.

The sheet.js in the trace is inside of the glamor package. That particular line looks like:

const oldIE = (() => {  
  if(isBrowser) {
    let div = document.createElement('div') // <--- this line 
    div.innerHTML = '<!--[if lt IE 10]><i></i><![endif]-->'
    return div.getElementsByTagName('i').length === 1
  }  
})()

isBrowser looks like:

const isBrowser = typeof window !== 'undefined'

(https://github.com/threepointone/glamor/blob/master/src/sheet.js)

Maybe there is a global.window defined in Storybook 3.3 that wasn’t there in 3.2?

P.S. I realize this is alpha release, but I figured I’d report it sooner rather than later if it is legit. Also, my setup is a tad bit complicated — I’m using react-native-storybook-loader — so I tried to create a vanilla CRNA/Storybook repo for you, but I couldn’t get past #1943.

Edit: Additional info

React Native: 0.47.2 Some npm ls output:

├─┬ @storybook/react-native@3.3.0-alpha.2
...
│ ├─┬ @storybook/addon-links@3.3.0-alpha.2
│ │ ├── @storybook/addons@3.3.0-alpha.2 deduped
│ │ ├─┬ @storybook/components@3.3.0-alpha.2
│ │ │ ├─┬ glamor@2.20.40

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
danielduancommented, Nov 6, 2017

verified fixed with PR ^

0reactions
krishna4157commented, Nov 2, 2019

I’m not sure what the best solution is but it probably involves separating the “UI” exports from addon-links from the “functionality” exports. @Hypnosphi, what do you think?

can u explain in detailed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Can't find variable: document" React Native error (3.3.0-alpha ...
Hello,. I am trying to get 3.3 up & running so that I can have accessibility labels (#1780) for Detox testing. Everything installs...
Read more >
React Native: can't find variable document - Stack Overflow
I am trying to add EventListner to document object but getting error as cant find variable document . Below is my code import...
Read more >
invariant violation: "main" has not been registered. this can ...
The most common cause of this error is that there is an exception thrown in your application before it's able to register itself....
Read more >
Firebase JavaScript SDK Release Notes - Google
Fixed a bug that caused Firebase SDKs to throw an error in Firefox browsers ... The SDK no longer causes React Native to...
Read more >
Releases - styled-components
Fix React Native components accepts function as style prop. ... it's possible to get into scenarios when multiple layers consume props by 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