JSFiddle - React, Tailwind, and code Playground
HTML
<input type="file" id="file"><img id="preview">
JavaScript
window.URL = window.URL || window.webkitURL || window.mozURL;
document.getElementById('file').onchange = function() {
var url = URL.createObjectURL(this.files[0]);
console.log(url);
document.getElementById('preview').src = url;
};