1

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 ?

3
  • It's not a browser so there is no window. I'm wondering exact what you're trying to do here... Commented Apr 8, 2015 at 8:52
  • This can be closed now. Window does get defined from react native however it seems to do it a tad too late. If in doubt use 'global' instead of window. Commented Apr 9, 2015 at 9:23
  • cool well just mark your own question as "answered" - that's as good as closing it. Commented Apr 9, 2015 at 9:56

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

Comments

0

downgrade react-native to version 0.55.4 will save your time

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.