DEV Community

Discussion on: Using Javascript Sets with React useState

 
ganes1410 profile image
Ganesh R

Hi, I am not saying Set should be the only thing used in this case. I am just saying it can be done using this way too. You are free to use whatever method suitable for your requirements.

Thread Thread
 
cmrdsenya profile image
Senya

With Set you don't have to implement duplication control manually, it provides it to you for free. If you add the same value for the second time, Set will just ignore it, while with Array you'll have the duplicate and you'll have to add more code to handle this case.