I'm trying to work with Firebase for the first time. I've set up the Firestore emulator and have put data in that I would like to retrieve in my Nextjs app. After initializing firebase, this is what my component looks like:
function Test() {
useEffect(() => {
const db = getFirestore();
connectFirestoreEmulator(db, "localhost", 8080);
async function testFirestore() {
const testRef = doc(db, "test", "testid");
const testSnap = await getDoc(testRef);
console.log("does not reach this line")
console.log(testSnap.data());
}
testFirestore();
}, []);
return <div></div>;
}
export default Test;
The problem is that I am getting nothing logged to the console. Not an error message, just nothing. The testFirestore function is running, but is seems to not get past the await getDoc() line. I also am not seeing requests coming in on the Firestore emulator. What am I doing wrong? I am sorry that I cannot be more specific, but there's no errors so it's hard to understand what is going on.
It seems to be an issue in Firebase JS SDK as mentioned in this Github issue. Upgrading to latest version should fix that issue.