Options
All
  • Public
  • Public/Protected
  • All
Menu

A wrapper for a React context for passing a database connection to ComponentWrappers.

Normally, you use this by creating an instance somewhere and sharing it between components via DatabaseProvider and useDatabase.

type DBSchema = NamedSchema<
  "myDatabase" | "myOtherDatabase",
  5,
  {
    favouriteColour: {
      key: string;
      value: {
        r: number;
        g: number;
        b: number;
      };
    };
  }
>;

const databasePromise = Database.open("myDatabase", 5);
export const DBContext = new DatabaseContext(databasePromise);

Type parameters

Hierarchy

  • DatabaseContext

Index

Constructors

Properties

Constructors

constructor

Properties

Consumer

Consumer: ExoticComponent<ConsumerProps<Database<DBSchema> | undefined>>

The consumer component for this context.

Use it to wrap components that need the database in the usual React consumer way.

database

database: Database<DBSchema> | Promise<Database<DBSchema>>

An open Database or a promise that will resolve to an one.

Generated using TypeDoc