I have the following code to render 5 stars for a component. I want it always to be exactly 5 stars, but depending on the rating, the rest of the stars should be blank. I have the following code to achieve this.:
const stars = []
for (let i = 0; i < 5; i++){
if (i < Math.floor(rating)){
stars.push(<span className="feedback-star full"></span>)
} else {
stars.push(<span className="feedback-star blank"></span>)
}
}
React is saying that I should have a unique key prop for each span. How should achieve this effectively? (I guess I could use new Date(), or Math.random(), but won't it be a lot of unnecessary operations on a list of over 100 feedbacks, each 5 stars?)