Module react-fsa-database

react-fsa-database

Overview

Most of the features of fsa-database wrapped with hooks for easy, clean component creation.

Features

Hooks

Hooks take care or reloading your data reactively in your components

State Management

Uses React Context for state management

Getting Started

Install

// using npm
npm install @philstenning/fsa-database

// using pnpm
pnpm i @philstenning/fsa-database

// yarn
yarn add @philstenning/fsa-database

Add context provider to your app

// app.tsx
// file extensions can be either '.md' or 'md'
import { FsaDbContextProvider } from '@philstenning/react-fsa-database'

function App() {
return (
<FsaDbContextProvider fileExtensionsForApp={['.txt', '.md', 'svg']}>
<YourApp></YourApp>
</FsaDbContextProvider>
)
}

export default App

Add a Root Directory

// TODO

List Files

// TODO

Add Collection

// TODO

Add File to collection

// TODO

Options

// list of folders that are not scanned.
excludedFolders: string[] = [
"node_modules",
"programFiles",
"junk",
".git",
".changeset",
"bin",
"__pycache__",
]

// list of extensions to scan for
fileTypes: string[] = ['jpg','png','gif']
// How deep you want to scan
maxDepth: number = 10

Settings

fsaSetting {
id?: number

// set internally when browser session starts
sessionStarted: number

// when files are removed from a collection,
// or a collection is deleted
// removed files from local disk also
cleanUpFiles: boolean

// when a file is added to collection
// save to disk
autoSaveCollections: boolean

scanInterval: number // default is 0 or none.

// time the user last scanned for file changes.
lastScanned: number

// when adding with drag and drop whether
// to add files to a new folder
allowDndFiles: boolean

// When resetting db retain all root Directories.
retainRootDirectoriesOnReset: boolean;

}

TypeScript

Fully written with TypeScript

Contributing

I'm open to all community contributions! If you'd like to contribute in any way, file an issue or pull request.

License

ISC

Index

Interfaces

Type Aliases

Functions - Context Provider

Functions - Hooks

Generated using TypeDoc