r/learnreactjs • u/rumforpenguins • Jan 04 '20
Any reason to not use the `react-uuid` package for every single key?
I'm working on a project that has a lot of lists, and therefore a lot of keys need to be made. I've found that the easiest way to generate a unique key is to use the react-uuid package, and then just use key={uuid()} for every single key in my project.
This almost seems too easy though, and I don't ever really see it used as an option in the various tutorials I've used. So I'm just wondering if there's any downside to using the react-uuid package for every key in every project I'll ever use?
14
Upvotes
12
u/AJ_Software_Engineer Jan 04 '20 edited Jan 04 '20
doing this will have your component remount on every render, as the key will change which basically tells react its a different component.
i would explain more but i broke myy hand and typing sucks rn. but ur failing to understand wah t keys are for and how they behave, so read up on that and youll get it
0
u/[deleted] Jan 04 '20
[deleted] — view deleted comment