An image preview package published live on npm
npm i image-preview-npm importImagefrom'legendary-image-preview';//use the image's getBase64Image function in your handler to get the base64 image and set it as the source of the img tag like so:\functionImagePreview(){const[imageSource,setImageSource]=useState('');//initialize your image object consthandleChange=(e)=>{letimage=newImage(e.target.files);//call the getBase64Image() of this object to get the image sourceimage.getBase64Image().then(res=>setImageSource(res));}return(<div><inputonChange={handleChange}type='file'/><imgsrc={imageSource}alt='preview'/></div>)}exportdefaultImagePreview;