4 ms·
Generating a random identifier grew my bundle size by 300kb
- PaulHoule 6y agoIt looks like he's drawing them from a pool of 1,000,000 integers which is fine so long as there are much fewer than 1000 items. With >1000 items you will have duplicates most of the time. See https://en.wikipedia.org/wiki/Birthday_problem https://en.wikipedia.org/wiki/Birthday_problem There is something to say for generating a (React) key from the underlying data, possibly applying a hash function, for instance sha384("geography:earth:jp:jp-17") In the semantic web we call it Skolemization https://en.wikipedia.org/wiki/Skolem_normal_form https://en.wikipedia.org/wiki/Skolem_normal_form but it's actually pretty simple. As for the 300kb one might think at first that that's not very much, but it is so easy to have 30 things that are like that and it all adds up to a funky situation.