I can use the following block in react to upload an image and show it:
function FileUpload() { const [file, setFile] = React.useState(""); function handleUpload(event) { setFile(event.target.files[0]); } return (<div id="upload-box"><input type="file" onChange={handleUpload} /> {file && <ImageThumb image={file} />}</div> );}const ImageThumb = ({ image }) => { return <img src={URL.createObjectURL(image)} alt={image.name} />;};
However, what's the equivalent of this in typescript. Especially with the event handler. Thanks!