React hook which provides a pickFiles
function to help you open a dialog to pick files.
npm install use-pick-files
yarn add use-pick-files
import * as React from 'react';
import { usePickFiles } from 'use-pick-files';
const Demo = () => {
const pickFiles = usePickFiles();
return (
<div>
<button
onClick={() => {
pickFiles().then(files => {
// `files` is an array of File instead of a FileList
console.log(files);
});
}}
>
Pick Files
</button>
</div>
);
};
(defaultOptions?: Options) => pickFiles
(options?: Options) => Promise<File[]>
accept?: string
multiple?: boolean