Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

221
Visualizações
react native possible uhandled promise rejection

im getting the following errors Possible Unhandled Promise Rejection (id: 0): TypeError: user.slice is not a function. (In 'user.slice()', 'user.slice' is undefined)

I need the code to be able to pass the data too return the list of users in order of most matching elements to least. I was able to get the function working in replit with a made up data base once I try to put it in my project I am getting trouble, please help.

 auth().onAuthStateChanged(user => {
          if (user) {
            // User is signed in, see docs for a list of available properties
            // https://firebase.google.com/docs/reference/js/firebase.User
            const profile = getUserProfile(user.uid);
            profile.then(pro => {
              const addy = pro.Address;
              setAddress(pro.Address);


              const filterdUsers = FBusers.filter(user => {
                if(user.Address === addy && user.uid !== p  pro.uid){
                  
                    const items = new Set(pro)
                    
                    const rank = arr => arr.filter(user => items.has(user)).length
                    
                    return (a, b) => rank(b.items) - rank(a.items)
              
                  
                }
                  const sorted = user.slice().sort(filterdUsers(pro))
                  
                  console.log(sorted.map(user => user.items.join(', ')))
                }
              )}};
              // sort users
              //setUsers(sortByMatch);
              //vvv delete me vvv
              setUsers(filterdUsers);

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

user is an object here and you can't slice an object. You can only slice an array or string

JavaScript Array Slice()

JavaScript String slice()

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda