I am making clone of Linkedin and trying to use snapshot but it says error
import firebase from 'firebase';
const firebaseConfig = {
apiKey: "mykey",
authDomain: "domain",
projectId: "linkedin-cl-37e0e",
storageBucket: "somedata",
messagingSenderId: "id",
appId: "id",
measurementId: "id"
};
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebaseApp.firestore();
const auth = firebase.auth();
export{db, auth};
export default firebase;
but for some reason it is not working it says the following:
Module not found: Error: Package path . is not exported from package D:\linkedin\my-app\node_modules\firebase (see exports field in D:\linkedin\my-app\node_modules\firebase\package.json) Did you mean './firebase'? Requests that should resolve in the current directory need to start with './'. Requests that start with a name are treated as module requests and resolve within module directories (node_modules, D:\linkedin\my-app\node_modules). If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
although i have done npm of firebase and tools as well. and for feed.js it says snapshot not defined
import React, { useState, useEffect } from 'react'
import './Feed.css'
import EditIcon from '@mui/icons-material/Edit';
import InputOption from './InputOption';
import ImageIcon from '@mui/icons-material/Image'
import SubscriptionsIcon from '@mui/icons-material/Subscriptions';
import EventNoteIcon from '@mui/icons-material/EventNote';
import CalendarViewDayIcon from '@mui/icons-material/CalendarViewDay';
import Post from './Post';
import { db } from './firebase';
import firebase from "./firebase";
function Feed() {
const[input, setInput] = useState('');
const[posts, setPosts] = useState([]);
useEffect(() => {
db.collection('posts').onSnapshot((onsnapshot) =>
setPosts(
onsnapshot.docs.map((doc) => ({
id: doc.id,
data: doc.data(),
}))
)
);
}, []);
const sendPost = (e) => {
e.preventDefault();
db.collection('posts').add({
name:'laeeq',
description:'this is a test',
message: input,
photoUrl:'',
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
});
};
this is the issue please help its already been 12 hours plus