I am working on a React project with Firebase (^9.6.7) and while I am configuring the Firebase database it shows such an error:
Compiled with problems: ERROR in ./src/App.js 28:4-17
export 'default' (imported as 'db') was not found in './firebase' (possible exports: auth, db, storage)
// in firebase.js
// v9 compat packages are API compatible with v8 code
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
const firebaseApp = firebase.initialzeApp({
apiKey: "AIzaSyCAxk5u3dc69u-OeGuQfR8IZYoj3dr1Kxo",
authDomain: "myinstagram-clone-fb535.firebaseapp.com",
projectId: "myinstagram-clone-fb535",
storageBucket: "myinstagram-clone-fb535.appspot.com",
messagingSenderId: "1061340472237",
appId: "1:1061340472237:web:d0b42559484d699a85b724",
measurementId: "G-9H2TSBPRSK"
});
const db = firebaseApp.firestore();
const auth = firebase.auth();
const storage = firebase.storage();
export { db, auth, storage }
// in app.js
import db from './firebase' // <- error here
CodePudding user response:
You have no export default XXXX
statement in your code.
To correctly import the db
object you exported using
export { db, auth, storage }
you must use
import { db } from './firebase'