rxdb
Version:
A local-first realtime NoSQL Database for JavaScript applications - https://rxdb.info/
25 lines (24 loc) • 1.09 kB
TypeScript
import React, { type ReactElement } from 'react';
import type { RxDatabase } from '../../types/index';
import { Provider } from './database-context.ts';
export type RxDatabaseProviderProps = {
database: RxDatabase;
children: React.ReactNode;
};
/**
* RxDatabaseProvider is a React context provider component for RxDB.
* It ensures that a valid RxDatabase instance is passed and makes it available
* to all descendant components via React Context.
*
* @param {RxDatabaseProviderProps} props - The provider props.
* @param {RxDatabase} props.database - The RxDatabase instance to provide.
* @param {React.ReactNode} props.children - The child components that will have access to the database.
* @throws {Error} If the provided database is not a valid RxDatabase instance.
* @returns {ReactElement} The context provider wrapping the children.
*
* @example
* <RxDatabaseProvider database={myDatabase}>
* <MyComponent />
* </RxDatabaseProvider>
*/
export declare function RxDatabaseProvider({ children, database, }: RxDatabaseProviderProps): ReactElement<typeof Provider>;