Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

216
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda