We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useLiveQuery
makePGliteProvider
The point of the PGliteProvider is:
PGliteProvider
to initiate a PGlite database and pass it to all child components for use with the usePGlite, useLiveQuery, and useLiveIncrementalQuery hooks.
However, makePGliteProvider only returns usePGlite:
usePGlite
const { PGliteProvider, usePGlite } = makePGliteProvider< PGlite & PGliteInterfaceExtensions<{...}> >()
This means when you make a type-aware PGliteProvider like this, it's not recognised by useLiveQuery and friends.
Uncaught Error: No PGlite instance found, use PGliteProvider to provide one
Here's a minimal repro:
import React, { useEffect, useState } from 'react' import { createRoot } from 'react-dom/client' import { PGlite, PGliteInterfaceExtensions } from '@electric-sql/pglite' import { makePGliteProvider, useLiveQuery } from '@electric-sql/pglite-react' import { type LiveNamespace, live } from '@electric-sql/pglite/live' type PGliteWithExtensions = PGlite & PGliteInterfaceExtensions<{ live: LiveNamespace }> const { PGliteProvider, usePGlite } = makePGliteProvider<PGliteWithExtensions>() function App() { const [db, setDb] = useState() useEffect(() => { async function init() { const pglite: PGliteWithExtensions = await PGlite.create({ extensions: { live, } }) setDb(pglite) } init() }, []) if (db === undefined) { return null } return ( <PGliteProvider db={db}> <Component /> </PGliteProvider> ) } function Component() { const results = useLiveQuery('select 1') return null } export function renderApp(el) { createRoot(el).render( <App /> ) } // const el = document.getElementById('app') // renderApp(el)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The point of the
PGliteProvider
is:However,
makePGliteProvider
only returnsusePGlite
:This means when you make a type-aware PGliteProvider like this, it's not recognised by
useLiveQuery
and friends.Here's a minimal repro:
The text was updated successfully, but these errors were encountered: