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

202
Views
How can I use .docs.find in V9 Firebase - Next.js?

This is currently what I have for Firebase v.8 but I need to understand how to implement it in V.9 so I can avoid receiving this error message:

TypeError: Cannot read properties of undefined (reading 'find')

function Sidebar() {
  const [user] = useAuthState(auth);
  const colRef = collection(db, 'chat');

  const userChatRef = query(
    colRef,
    where('users', 'array-contains', user.email)
  );
  const chatsSnapshot = userChatRef;

  const createChat = () => {
    const input = prompt('Please enter an email address');

    if (!input) return null;

    if (
      EmailValidator.validate(input) &&
      !chatAlreadyExists(input) &&
      input !== user.email
    ) {
      setDoc(doc(collection(db, 'chats')), {
        users: [user.email, input]
      });
    }
  };

  const chatAlreadyExists = (recipientEmail) => {
    !!chatsSnapshot?.docs.find(
      (chat) =>
        chat.data().users.find((user) => user === recepientEmail)?.length > 0
    );
  };

Database for 'user'

about 4 years ago · Juan Pablo Isaza
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!