#can't fix duplicates in array

26 messages · Page 1 of 1 (latest)

torn badgeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

neon yacht
#

in strict mode IIRC, the useEffect runs two times

#

so the data is populated first time

#

but then again data is getting added to the array

#

would you explain what you're trying to do? to explain the answer better

finite trail
#

i am trying to get all different eventUpdates from the function getEventUpdates

#

so if there are duplicates they wouldnt be added to the array

neon yacht
#

so you get like new update of that event everytime the eventId is changed?

finite trail
#

no i just get a few same objects everytime it is called, but somewhy the function gets called two times, so there are duplicates

neon yacht
#

you can disable strict mode if you want?

finite trail
neon yacht
#

^ to disable in next.js

#

^ in good old react

finite trail
#

removing duplicates is more reliable, because changing strict mode could couse my other functions to break

neon yacht
#

noice

#

I saw somewhere, that strict mode should not cause issues for our code

#

IDK

finite trail
#

ill try to fix by removing duplicates, this code almost seems right, just a small mistake somewhere here

neon yacht
#

yeah, good luck

mint dock
#

Use a Set instead of an Array. It's a data type which does not allow duplicates

finite trail
#

i need to keep the order of the items

mint dock
#

Sets are ordered

finite trail
#

i get an error trying to map the set, can you map them??

neon yacht