-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting seed does not return same set of colours! #132
Comments
Hello Ethan, thank you for this report. Which version of the library are you using (you can find this in your copy of this repo's package.json file). And what seed input are you using? It would be great if you could share your full usage of the script, e.g. randomColor({count: 5, seed: 'foo'}); |
I'm having the same issue. If I just reload the page, the color stays the same, but if I change anything in the code (even if it's not related to the color generating options), the color changes every time, despite passing the same seed. And it doesn't seem to matter whether I pass the seed as an argument or hard-code it. I have a small util that goes like this:
But even if I call randomColor directly in my components, the problem doesn't go away. Modifying any surrounding code breaks same-color generation from seed. |
I think it only breaks on hot reload. If I refresh the page manually, the seed seems to generate consistent colors every time. My project is on Vue 2. |
Edit: Scrap that. Even with memoisation I was still running into issues. I then tried your version @sanyavanya, but kept getting: So I did two things that fixed it (at least for React).
Would be interesting to create a hook version of randomcolor... |
If I set count = 5, and generate the colours twice with same seed, they give a different list of colours!
The text was updated successfully, but these errors were encountered: