Made with create-react-library
npm install filedrivejs
const { ref, list, navigate, back, open, error } = useFileSystem()
`
| Key | Type | Description |
| -------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| ref | React.RefObject | (required) This ref must me attached to a button element, upon click on that button popup will open to select directory. |
| list | List[] | This contains the metadata about the current directory's file and folders. |
| navigate | (name: string, handle: FileSystemDirectoryHandle) => Promise | This function is used to navigate to a new directory |
| back | () => Promise | This function is used to navigate back to the previous directory |
| open | (handle: FileSystemFileHandle) => Promise | This function will open the file in new tab, If the filetype is not supported by the browser it will be downloaded |
| error | string | This contains the error message if any error occurs |
#### Example
`js
const App = () => {
const { ref, list, navigate, back, open, error } = useFileSystem()
return (
{error && Error: {error}
}
{list.map((item, idx) => (
key={idx}
onClick={() => {
if (item.type === 'directory')
navigate(item.name, item.handle)
else open(item.fileHandle)
}}
>
{item.name} - {item.type} - {item.size}
))}
)
}
``