Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the input is required and we use drag and drop to upload the file, then on form submit, it says field is required. #123

Open
SciSaif opened this issue Jun 9, 2023 · 2 comments

Comments

@SciSaif
Copy link

SciSaif commented Jun 9, 2023

If the input is required and we use drag and drop to upload the file, then on form submit, it says field is required even if the file is uploaded, so it doesn't let me submit.
right now I am handling the required part manually.

@jpiazzal
Copy link

jpiazzal commented Feb 9, 2024

I have the same problem too, is there a way to avoid this problem?

I would avoid to add required as a state if possible.

The code is the same as in the example, i just added the field required:

import React, { useState } from "react";
import { FileUploader } from "react-drag-drop-files";

const fileTypes = ["JPG", "PNG", "GIF"];

function DragDrop() {
  const [file, setFile] = useState(null);
  const handleChange = (file) => {
    setFile(file);
  };
  return (
    <FileUploader handleChange={handleChange} name="file" types={fileTypes} required />
  );
}

export default DragDrop;

@MariusMez
Copy link

Hi, same issue here, wondering if anybody has found a way to deal with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants