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

59
Vistas
React .some unintended behaviour on render

I am getting an array of posts data from a server, and then i am mapping over it. Inside each post there is an array of IDs of users who liked the post. I am trying to tell the user if it liked the post already:

 {!postLikes.some((didLike) => didLike._id === currentUser) ? (---DidNotLike---) : (---Liked---)

The idea is, if the user did not like the post, and likes it after the post has loaded, the ternary expression works, but the first time it renders it does not work. I checked with console logs that the array is in fact loaded in time and that the currentUser ID matches a value from the array.

If i use

{postLikes.includes(currentUser) === true && (---Liked---)}

then when posts render for the first time, it shows which posts the user liked, but it does not give feedback when it likes others (until re-render). What could be the cause?

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