Question:
In my application, I assign the same random color for the background color of the sameuniqueID
and I also want this color to be the same random color if the page reloads.My approach and current behavior is similar to the solution in this prior post: Generate Random Same Colors in React however, the colors change if the page is reloaded.
Question: Is there a way to map the
uniqueID
to a random color, and have it persist different instances of my app using REACT?See below my current code:
Answer:
You could use one of the various storage options to store this and then restore on each page load:If you have better answer, please add a comment about this, thank you!