Reference Components and hooks
Components and hooks
What an application of React needs is in this one package; what it shares with the drive without a framework is exported from it too.
On this page
Exports
| Name | What it is |
|---|---|
| FileDrive | The whole drive. |
| SharedLink | What someone sent a link sees, without signing in. |
| createMemoryClient | The drive kept in the page, with the client of the server’s routes. |
| createDriveClient, createLinkClient | The clients, from @rebofiles/drive. |
| RequestError | What the server refused: its status, its code and its message. |
| TEXTS, formatSize, formatDate, formatDuration, kindOf | The words, and what is said of a file. |
| @rebofiles/react/rebodocs | previewDocx, viewDocx, thumbDocx, pictureOfDocx, textOfDocx: Word documents by Rebodocs’ engine. |
Hooks
| Hook | What it does |
|---|---|
| DriveProvider | The client and the words, for every hook under it. base, client, headers, language, texts, live; a <FileDrive> inside it uses the same. Every hook asks again when someone else changes the drive. |
| useEntries | A folder, Recent, Starred, what came through requests, Shared with me, the trash or a search. entries, path, loading, error, refresh: asked again after every change. |
| useEntry | One entry as it is now, and where it is. entry, path, trashed; null while it loads, or when there is none. |
| useActions | What changes the drive, telling every hook after. createFolder, rename, move, moveToTrash, restore, deleteForever, emptyTrash, restoreVersion, copy, star, setColor, setFields, review, share, unshare, createLink, removeLink, linkToken, upload, url. |
| useUploads | Files going up, three at a time, with the time each has left. uploads, summary, upload, retry, stop, stopAll, decide, dismiss, clear; { check: true } to ask about what is there already. |
| useSettings | The drive’s settings and the person’s own. settings, drive, mine, canConfigure, save, saveMine. |
| useComments | What is said of an entry, and saying more. comments, loading, error, add, edit, resolve, remove. |
| useActivity | Who did what to an entry, the newest first. activity, loading, error; useActivity(id, limit?). |
| useTextSearch | The files with these words written inside, each with a piece of its text. results (entry, snippet), loading, error; none for an empty query. |
| useNotifications | What the one asking was told, and how many are new. notifications, unseen, loading, error, saw(). |
| useRequests | The requests for files one has made. requests (folder, link, token), loading, error, remind(folder, link). |
| useExpiring | The files whose field expires comes within so many days, or passed: the soonest first. files (entry, expires, days), loading, error; useExpiring(days?), 15 unless said. |
| useWithField | The entries with a field of this value: the files of one record of yours. entries, loading, error; none without a value. |
| usePeople | Who matches what is typed, from your directory, to share with. people, loading, error; none for an empty query. |
| useDrive | The provider itself. client, revision, changed(), t, locale, settings: every route as a function, a number that goes up after each change, and the drive’s words. For what has no hook of its own. |
Every prop of <FileDrive>
| Prop | Type | What it does |
|---|---|---|
| base | string | Where the routes of @rebofiles/server are. /api/files unless said. |
| client | DriveClient | A client of your own instead of base: the drive kept in the page (createMemoryClient), or one shared with the rest of the page. |
| headers | () => Record<string, string> | Headers for every request to your server, such as a token of the session; never sent to the bucket. May be async. |
| linkAddress | (token) => string | Where a link of the drive points: your page with <SharedLink>. This page with ?link= unless given. |
| settings | boolean | false leaves out the screen of settings and the button that opens it. |
| language | 'en' | 'es' | 'zh' | Under each person’s own choice, over the drive’s. English unless given. |
| texts | Texts | The words of another language, with the keys of TEXTS.en. |
| theme | 'light' | 'dark' | 'auto' | Under each person’s own choice, over the drive’s. auto follows the system. |
| title | string | The name over the drive: your application’s, or “Files”. |
| logo | ReactNode | What goes before the title; ReboFiles’ mark unless given. A Node for mountDrive. |
| defaultView | 'list' | 'grid' | How a folder is shown the first time. |
| layout | 'full' | 'compact' | compact: no column on the left; New and the places in a strip over the list, for a drive in a smaller part of a page. |
| className | string | A class of your own on .rf-drive, for its custom properties. |
| chrome | boolean | false leaves out its bar and its sections, for your application’s own around it: it drives it with go, search, upload, newFolder, requestFiles, share, openSettings. |
| root | EntryId | The folder it is kept in, as the files of one record of yours: it starts there, its path starts there, nothing above it. |
| onState | (state) => void | Where it is, each time that changes: the section, the folder and its path, what is searched, how many, the space; for your own bar. |
| controls | RefObject<DriveControls> | React: the drive’s go, search, upload, newFolder, requestFiles, share and openSettings, put in it while it is there. |
| checkUploads | boolean | false uploads without looking for the same file, or one of its name, in the drive first: a taken name is made free with “(2)”. |
| requestTemplates | boolean | false leaves out the templates of requests: to start one from, and to save one as. |
| qr | boolean | false leaves out the QR code of a request made. |
| onOpen | (file, url) => void | A file opened by a double click or Enter, your own way. Unless given, the drive’s viewer shows it. |
| fields | 'show' | 'edit' | false | The fields of your application on an entry, in its details: shown (as it comes), changed there by who may rename it (edit), or left out. |
| previewDocument | (bytes) => DocumentPreview | The details of a .docx: its title and first paragraphs. previewDocx. |
| viewDocument | (element, bytes) => ShownDocument | The viewer of a .docx: its pages, one by one or all, with Rebodocs’ zoom and print. viewDocx. |
| thumbDocument | (bytes) => Promise<HTMLElement> | Its first page drawn in the grid, until a picture of it is made. thumbDocx. |
| pictureDocument | (bytes, size, type, quality) => Promise<Blob> | Its first page as a picture, made at upload and kept as its thumbnail in the drive’s sizes. pictureOfDocx. |
| textDocument | (bytes) => string | What is written in it, sent at upload, for a search to find it by. textOfDocx. |
| onOpenDocument | (file, url) => void | Gives a .docx an “Open in Rebodocs” button, called with an address to read it from. |
| compareDocument | (element, before, after) => ShownDocument | “Compare” on each version but the current, in the history: what changed, over its pages. compareDocx. |
| newDocument | () => Uint8Array | “New document” in the Upload menu: an empty .docx named by the person, in the folder they are in, then opened. newDocx. |
| onChange | () => void | After every change made from the drive, for what else in the page shows it (mountDrive; in React, the provider tells the hooks). |
| live | boolean | What others change, shown as it happens, from the server’s /events. true unless said; in React, the provider’s. |
By what they are for, with examples: React component.