UNPKG

rxdb

Version:

A local-first realtime NoSQL Database for JavaScript applications - https://rxdb.info/

19 lines (18 loc) 649 B
import { useContext } from 'react'; import { RxDatabaseContext } from "../database-context.js"; import { newRxError } from "../../../rx-error.js"; /** * The `useRxDatabase` hook retrieves the RxDB database instance from context. * * @returns The RxDB database instance. * @throws {Error} Throws an error if the component is not wrapped in a <RxDatabaseProvider>. * This ensures the database context is properly initialized before use. */ export function useRxDatabase() { var database = useContext(RxDatabaseContext); if (database == null) { throw newRxError('R2'); } return database; } //# sourceMappingURL=use-rx-database.js.map