ThomasThiebaud ThomasThiebaud - 1 year ago 81
React JSX Question

Random image link render the same across a list of element

I'm using

and I would like to render a list (
) of items (
) with random images as an avatar. I found this link which allow you to easily get a random image.

My item looks like


and each time I create a new item I have a random image like this

enter image description here

But if I refresh the page, all the images become the same

enter image description here

All my items are different, so why are the image the same ? If I refresh again an again, the image change, but it is still the same for all the items.

Answer Source

Most probably having the same URL, the browser will not download the image again for each occurrence, so you should add a unique identifier:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download