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

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (12 by maintainers)

Most upvoted comments

verified fixed with PR ^