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

firestore not a function #3

Open
wchesley opened this issue Mar 25, 2019 · 8 comments
Open

firestore not a function #3

wchesley opened this issue Mar 25, 2019 · 8 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed invalid This doesn't seem right

Comments

@wchesley
Copy link
Owner

Error code: TypeError: _firebase__WEBPACK_IMPORTED_MODULE_0__.default.firestore is not a function

Error thrown in ./src/firebase/db.js
Line 3: const db = Firebase.firestore();

@wchesley wchesley added bug Something isn't working help wanted Extra attention is needed invalid This doesn't seem right labels Mar 25, 2019
@JCmusik
Copy link

JCmusik commented Mar 25, 2019

Check to see if you’re importing Firebase at the top of your component next to import React from ‘react’.

@JCmusik
Copy link

JCmusik commented Mar 25, 2019

const db = firebase.firestore();
The first firebase shouldn’t be capitalized

@wchesley
Copy link
Owner Author

The Firebase instance is exported from firebase.js as export default Firebase changing the case causes firebase to become undefined.

@JCmusik
Copy link

JCmusik commented Mar 26, 2019

In your ./src/firebase/db.js try adding the following import at the top.
import * as firebase from 'firebase';

Got this idea from stack overflow and comparing your code to mine.

@wchesley
Copy link
Owner Author

well changing the import statement does change the error message:
Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)

However, in firebase.js we have app.initializeApp(config);

I also tried moving all db.js logic into firebase.js and achieved the same results.

@JCmusik
Copy link

JCmusik commented May 5, 2019

Try this below (:
import * as firebase from 'firebase';
import 'firebase/firestore'; <--- add this line here to your code

@wchesley
Copy link
Owner Author

wchesley commented May 5, 2019

Seem to point db.js towards the actual firebase library rather than my code to initialize firebase.

Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).

But, changing the import statement to: `import * as firebase from './firebase' we get this:

Failed to compile
./src/firebase/db.js
Attempted import error: 'firestore' is not exported from './firebase' (imported as 'firebase'). 

I'm going to have to reread firestore docs before attempting to fix this again.

@Phezzalicious
Copy link
Collaborator

Phezzalicious commented May 5, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants