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

282
Views
Problema al filtrar la barra de búsqueda en next.js con firebase

Estoy creando una aplicación de chat usando next.js y firebase. El problema es que estoy tratando de crear una barra de búsqueda que filtre por el correo electrónico del usuario. El filtro solo funciona para los correos electrónicos que están en el índice 0 de la matriz. Cualquier pista ? La matriz de usuarios contiene los usuarios que están en el chat. La matriz del documento se ve así: ingrese la descripción de la imagen aquí

 const [searchTerm,setSearchTerm]=useState(""); const [user]=useAuthState(auth) const userChatRef=db.collection('chats').where('users','array-contains',user.email) const[chatsSnapshot]=useCollection(userChatRef) render( <Search> <SearchIcon/> <SearchInput style={{fontFamily:"Roboto",fontSize:"calc(6px + 0.3vw)"}} type="text" placeholder="Pesquise uma conversa" onChange={(event) => { setSearchTerm(event.target.value); }} /> </Search> {chatsSnapshot?.docs.filter((user)=>{ console.log(user.data().users.findIndex(email =>email !== user.email )) if(searchTerm==""){ return user } else if (user.data().users[user.data().users.findIndex(email =>email !== user.email )].toLowerCase().includes(searchTerm.toLowerCase())){ return user } }).map((chat)=>( <Contact key={chat.id}> <Chat id={chat.id} users={chat.data().users}></Chat> <Line/> </Contact> ))} ) const Search=styled.div` display: flex; align-items: center; padding:5px; border-radius:2px; height:60px; background-color:#f1f2f6; border-radius:5px; `; const SearchInput= styled.input` outline-width:0; border:none; flex:1; font-size:15px ; margin-left:10px; background-color:#f1f2f6; min-width:10vh; font-size:calc(3px + 0.5vw); font-family: 'Roboto';
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!