Untitled

mail@pastecode.io avatarunknown
plain_text
a month ago
444 B
1
Indexable
Never

  const [file, setFile] = useState<File | string>();
  const [previewImage, setPreviewImage] = useState<string>();
  function handleChangeImage(e: React.ChangeEvent<HTMLInputElement>) {
    // console.log(e.target.files);
    if (!e.target.files) return;
    setFile(e.target.files[0]);

    setPreviewImage(URL.createObjectURL(e.target.files[0] || null));

    dispatch(updateImagePreview({ data: { imagePreview: e.target.files[0] } }));
  }