display preview of image upload react
<!-- html + Javascript -->
//js
<script>
const handleChange = (e) =>{
const file = URL.createObjectURL(e.target.files[0])
document.getElementById("preview-img").src = file;
}
document.getElementById("file-input").addEventListener("change", handleChange);
</script>
//html
<div>
<input id="file-input" type="file"/>
<img id="preview-img" src="" width="200"/>
</div>