Open file dialog without struggling with file input using useFileDialog react hook.
You can install use-file-dialog
with NPM or Yarn.
npm install use-file-dialog
yarn add use-file-dialog
Here's how to use use-file-dialog
:
import useFileDialog from "use-file-dialog";
function App() {
const { files, openFileDialog } = useFileDialog();
console.log(files);
return (
<button type='button' onClick={openFileDialog}>Choose file</button>
);
}