import { initializeApp } from "firebase/app";
import { getFirestore } from 'firebase/firestore/lite';
const firebaseConfig = {
apiKey: "AIzaSyBOK7x5N5UnjY4TDqndzH7l5tvdNIsWFRc",
authDomain: "todo-app-e3cf0.firebaseapp.com",
projectId: "todo-app-e3cf0",
storageBucket: "todo-app-e3cf0.appspot.com",
messagingSenderId: "940016886081",
appId: "1:940016886081:web:91686613f16b1b1f8001c0",
measurementId: "G-JHPC7TP12K"
};
const firebaseApp = initializeApp(firebaseConfig);
const db = getFirestore(firebaseApp);
export default db;
firebase Code
useEffect(()=>{
//Get Value from Db
db.collection('Todos').onSnapshot(Snapshot=>{
console.log(Snapshot.docs.map(doc=>doc.data().Todo))
// setTodo(Snapshot.docs.map(doc=>doc.data().Text))
})
},[])
Encountered the error while create a todo list To get data from the firestore. The JS code uses On snapshot but wasnt working so console.logged it to see error.