Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
444 B
3
Indexable

  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] } }));
  }