Closed harveyappleton closed 4 years ago
@harveyappleton Welcome to the open-source contribution world!
I totally agree, instead of trying to add a bit more of uniqueness each time, probably better to go directly with uuid so we shouldn't have any other problem moving forward.
Thanks for your PR!
Sounds good, happy to investigate this and do a new pull req with uuid integrated!
@jeremybarbet - rather than depending on another library (uuid), what about using a simple unique function? eg - https://gist.github.com/gordonbrander/2230317#gistcomment-3404537
@harveyappleton Sure sounds good, let's try that!
@jeremybarbet I ended up using the UUID library because the gist i linked to there sadly didnt work as it also relied on Date.now() for randomness. Preliminary tests seem to show 5 portals on 1 react navigation screen working well!
Appreciate any feedback as TS / OpenSource contribution goodness is new to me, think I've done it correctly but appreciate any comments :-) thanks guys
Thank you! I will release a new version so you can try it out :)
Edit: 1.0.6
now available
Oh I see it is time for me to magically reappear!
The github gist - as you mentioned - is just an extra letter of the alphabet away from "Date.now() + a random number", but I think this approach seemed "good enough".
Upon testing 1.0.6
in my app, I immediately got the following error: https://github.com/uuidjs/uuid#getrandomvalues-not-supported
When I follow these instructions to install the polyfill in my project - things work great and I don't seem to have any more issues with multiple instances. I'm going to run with it on my project.
Throwing it back to you peeps! (Through a new github issue... sorry)
@edc123 Fix landed in 1.0.7
Avoids issues where multiple portals on one screen can have same key (Date.now() is not sufficient on its own if rendering is fast enough).
Could look at using something like uuid instead of a random number to guarantee more uniqueness? 👍