Net Ninja's React Redux & Firebase Tutorial(2018)
Currently working through this tutorial, and in 5:56 into his tutorial, he is in projectActions.js. The code presented is the exact replica of my code. However I get this error:
TypeError: firebase.collection is not a function
Here is my code:
export const createProject = (project) => {
return (dispatch, getState, { getFirebase, getFirestore}) => {
//make an async call to firebase
const firebase = getFirestore();
firebase.collection('projects').add({
...project,
authorFirstName: 'Net',
authorLastName: 'Ninja',
authorID: 12345,
createdAt: new Date(),
}).then(() => {
dispatch({ type: 'CREATE_PROJECT', project});
}).catch((err) => {
dispatch({ type: 'CREATE_PROJECT_ERROR', err});
})
}
};
Looked through Firebase's docs, but with no avail, so unsure how to resolve this error
Thanks for any help
Edit 1
As requested, my config file(data removed):
// Import the functions you need from the SDKs you need
import { initializeApp } from 'firebase/app';
import { getAnalytics } from 'firebase/analytics';
import firebase from 'firebase/compat/app';
import 'firebase/firestore';
import 'firebase/auth';
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
export default firebase;
