2

State variable:-

const [picture, setPicture] = useState(null);

Let suppose picture="123" after updating image picture has same same value "123".So my question is how to reload Image.

<Image src={profileurl + picture} alt="profile" title="profile" width="100" height="100" />
dattu
  • 43
  • 4
  • Does this answer your question: [Refresh image with a new one at the same url](https://stackoverflow.com/questions/1077041/refresh-image-with-a-new-one-at-the-same-url)? – juliomalves Jun 27 '22 at 21:53

1 Answers1

-1

I hope this function would be helpful. thanks

const reloadImg = url => {
    fetch(url, {cache: 'reload', mode: 'no-cors'})
      .then(() => document.body.querySelectorAll(`img[src='${url}']`).forEach(img => (img.src = url)))
      .catch(e => console.log('error', e));
  };
Ahmad Faraz
  • 1,371
  • 1
  • 4
  • 11