简体   繁体   中英

React Native Can't find variable: window"

Attempting to port a react web project over to native I'm getting the following:

React Native Can't find variable: window"

This is most likely due to me requiring react and attempting to give it global scope with window.React = require('react-native'); .

What's curious is the project runs fine if I enable debugging with chrome.

If the above is incorrect how do I set a global scope with react native ?

React needs to be initialised before the window object can be accessed. Regardless of this in general global is preferred(which is what you would use when developing in node).

downgrade react-native to version 0.55.4 will save your time

ref: https://github.com/facebook/react-native/issues/20015

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM