display preview of image upload react
//ReactJs
import {useState } from "react";
export default function Home() {
const [file, setFile] = useState("")
const handleChange = (e) =>{
setFile(URL.createObjectURL(e.target.files[0]))
}
return (
<div>
<input type="file" onChange={handleChange}/>
<img src={file}/>
</div>
)
}