Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
TypeError: Object(...) is not a function when connecting with Firebase

So, I was following a tutorial on a messenger clone and they used Firebase. When I used that syntax it showed me error and later i found out they changed the whole syntax. So I tried to do the thing this way and its giving me this typerror.

import db from "./firebase";
import { doc,onSnapshot,collection,query } from 'firebase/firestore';
.....
.....
  const [messages, setMessages] = useState([
          {username: "Shuvo", message: "What's up"},
          {username:"Arnob",message:"Hi"}]);

  useEffect(()=>{
    const q = query(collection(db,"messages"));
    const hello = onSnapshot(q,(querySnapshot)=>{
      setMessages(querySnapshot.docs.map(doc => doc.data()))
    })
  },[])
.....
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  useEffect(()=>{
    const ref = firebase.firestore().collection('messages')
    ref.onSnapshot((querySnapshot)=>{
      const items = []
      querySnapshot.forEach((doc)=> items.push(doc.data()))
    setMessages(items)
    })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!