Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firebase is not defined #19

Open
ursvasan opened this issue Mar 12, 2023 · 3 comments
Open

firebase is not defined #19

ursvasan opened this issue Mar 12, 2023 · 3 comments

Comments

@ursvasan
Copy link

I am new to JavaScript, may be i am missing something obvious. Ideally it should have worked as it is.

I run the app and in Registration screen I get the following error. I tried googling for the issue and tried to include

  <head>
    <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
  </head>

I still get the error below. What am i missing ?

Uncaught ReferenceError: firebase is not defined
at onRegisterPress (RegistrationScreen.js:21:1)
at onPress (RegistrationScreen.js:96:1)
at onClick (PressResponder.js:348:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
at invokeGuardedCallback (react-dom.development.js:4277:1)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:1)
at executeDispatch (react-dom.development.js:9041:1)
at processDispatchQueueItemsInOrder (react-dom.development.js:9073:1)
at processDispatchQueue (react-dom.development.js:9086:1)

@ursvasan
Copy link
Author

ursvasan commented Mar 12, 2023

I figured I didnt include the line

import { firebase } from '../../firebase/config'

in RegistrationScreen.js and thats the reason for the above error. Now firebase is loading but still registration screen is not working.
I get the following error when i call firebase.auth() in RegistrationScreen.js > onRegisterPress

Uncaught TypeError: _firebase_config__WEBPACK_IMPORTED_MODULE_4__.firebase.auth is not a function

I have the following in ./src/firebase/config.js


var firebase = require("firebase/app");
require("firebase/auth");
require("firebase/firestore");

const firebaseConfig = {
  apiKey: 'xxxxx',
  authDomain: 'abcd.firebaseapp.com',
  databaseURL: 'https://xyz.firebaseio.com',
  projectId: 'xyz',
  storageBucket: 'xyzappspot.com',
  messagingSenderId: '12345',
  appId: '1:123456',
};

firebase.initializeApp(firebaseConfig);
console.log(firebase);
export { firebase };

@ursvasan
Copy link
Author

Turns out I am using Firebase 9.x and it has lot of breaking changes and this tutorial is based on a older version. For the latest changes refer to the article

@rybaier
Copy link

rybaier commented May 6, 2024

@ursvasan I know this is a bit late but if you wanted a reference for the Firebase 9 modular SDK you can find it here @
https://github.com/rybaier/react-native-firebaseModular ( I updated all the syntax and made a pull request)

I also created my own repo of it and added a few more features like SSO for Google and Apple, deleting accounts, update and delete for entities, and log out. you can find it here @ https://github.com/rybaier/react-native-firebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants