How to force React to reload an image file? I think that’s because of the browser cache. try adding some hash like date.now() after image URL changes. for example:
1 2 3 4 |
setState({ imageSrc: '...', imageHash: Date.now() }) |
and in render:
1 2 3 4 5 |
render(){ return( <img src={`${imageSrc}?${imageHash}`} /> ) } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.