wchesley / React-Pizza

React Project for mobile app dev class I am enrolled in for spring 2019
0 stars 0 forks source link

firestore not a function #3

Open wchesley opened 5 years ago

wchesley commented 5 years ago

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();

JCmusik commented 5 years ago

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

JCmusik commented 5 years ago

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

wchesley commented 5 years ago

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

JCmusik commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

wchesley commented 5 years ago

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 commented 5 years ago

It didn't work for me either, just the red screen of death

On Sun, May 5, 2019, 1:21 PM Walker Chesley notifications@github.com wrote:

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.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/wchesley/React-Pizza/issues/3#issuecomment-489450461, or mute the thread https://github.com/notifications/unsubscribe-auth/AKIHJXBF2BLW6YOK6ITUVDDPT4QTRANCNFSM4HAX7SEA .