Simple react hook to open browser file selector.
π Homepage
npm i use-file-picker
https://codesandbox.io/s/pedantic-joliot-8nkn7?file=/src/App.js
import { useFilePicker } from 'use-file-picker';
function App() {
const [filesContent, errors, openFileSelector, loading] = useFilePicker({
multiple: true,
// accept: '.ics,.pdf',
accept: ['.json', '.pdf'],
});
if (errors.length > 0) return <p>Error!</p>;
if (loading) {
return <div>Loading...</div>;
}
return (
<div>
<button onClick={() => openFileSelector()}>Reopen file selector</button>
<pre>{JSON.stringify(filesContent)}</pre>
</div>
);
}
π€ Milosz Jankiewicz
- Twitter: @twitter.com/JankiewiczMi/
- Github: @Jaaneek
- LinkedIn: @https://www.linkedin.com/in/jaaneek
π€ Kamil Planer
- Github: @MrKampla
- LinkedIn: @https://www.linkedin.com/in/kamil-planer/
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a βοΈ if this project helped you!
This README was generated with β€οΈ by readme-md-generator