Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when running Firebase 3.0 with React Native

Tags:

Just loaded firebase 3.0 with react-native and getting the error

[fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: Can't find variable: document

Is react-native supported yet?

React-native code:

var firebase = require('firebase')  // Initialize Firebase var config = {     apiKey: '<apiKey>',     authDomain: '<app>.firebaseapp.com',     databaseURL: 'https://<app>.firebaseio.com',     storageBucket: 'firebase-<app>.appspot.com' }; firebase.config(config) 
like image 320
poxion Avatar asked May 18 '16 23:05

poxion


1 Answers

The newest version of firebase uses the document variables that are used in web applications and the RCTWebSocket or RCTView doesn't work the same way. (I'm not 100% sure about all the details). Anyway, you can just install an older version of firebase and it will work for you. Assuming you have npm installed follow these instructions.

  1. Uninstall Firebase from your react-native project npm uninstall firebase --save
  2. Install version 2.4.2 of firebase npm install [email protected] --save
  3. Happy Firebaseing!
like image 168
gbland777 Avatar answered Sep 24 '22 04:09

gbland777