react-indexeddb-kit
Version:
A TypeScript-based React IndexedDB wrapper with CRUD operations.
16 lines (15 loc) • 544 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useIndexedDB = void 0;
// src/hooks/useIndexedDB.ts
const core_1 = require("../core");
const react_1 = require("react");
const useIndexedDB = (dbName, schema) => {
const [client, setClient] = (0, react_1.useState)(null);
(0, react_1.useEffect)(() => {
const db = new core_1.ReactIndexDBClient(dbName, schema);
db.connect().then(() => setClient(db));
}, [dbName, schema]);
return client;
};
exports.useIndexedDB = useIndexedDB;