@tanstack/react-db
Version:
React integration for @tanstack/db
24 lines (23 loc) • 623 B
JavaScript
"use client";
import { jsx } from "react/jsx-runtime";
import { createContext, useContext } from "react";
const DbContext = createContext(void 0);
function DbProvider(props) {
return /* @__PURE__ */ jsx(DbContext.Provider, { value: props.client, children: props.children });
}
function useDbClient() {
const client = useContext(DbContext);
if (!client) {
throw new Error(`useDbClient must be used within a DbProvider.`);
}
return client;
}
function useOptionalDbClient() {
return useContext(DbContext);
}
export {
DbProvider,
useDbClient,
useOptionalDbClient
};
//# sourceMappingURL=DbProvider.js.map