Skip to content

opens files chooser twice #50

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

Open
neutron92 opened this issue Feb 25, 2025 · 0 comments
Open

opens files chooser twice #50

neutron92 opened this issue Feb 25, 2025 · 0 comments

Comments

@neutron92
Copy link

hello
this is my component but when i click in the zone it open the window to choose file after choosing the file it open it again

import { useEffect, useState } from 'react';
import { Dropzone, ExtFile, FileMosaic } from '@files-ui/react';

export const DropZoneComp = ({
  setDocuments,
}: {
  setDocuments?: (files: ExtFile[]) => void;
}) => {
  const [files, setFiles] = useState<ExtFile[]>([]);
  const updateFiles = (incommingFiles: ExtFile[]) => {
    setFiles(incommingFiles);
    setDocuments?.(files);
  };

  const removeFile = (id: number | string | undefined) => {
    setFiles(files.filter((x) => x.id !== id));
  };

  return (
    <div className="flex flex-col max-w-full overflow-hidden">
      <Dropzone maxFileSize={20000} value={files} onChange={updateFiles}>
        {files.length > 0 &&
          files.map((file: ExtFile) => (
            <FileMosaic
              {...file}
              onDelete={removeFile}
              key={file.id}
              info
              preview
            />
          ))}
      </Dropzone>
    </div>
  );
};

export default DropZoneComp;
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

1 participant