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

67
Views
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
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!