Function: useLiveQuery()
Function: useLiveQuery()
Section titled “Function: useLiveQuery()”useLiveQuery<
TRow>(queryFactory,deps):TRow[]
Defined in: react/src/use-live-query.ts:30
Subscribe to a reactive select for the current component.
The queryFactory builds the plasma select and MUST be pure — it is
re-evaluated whenever deps change. Wrap variables the factory closes
over in deps so the subscription re-attaches when they move (matching
the ergonomics of React’s own useMemo / useEffect).
const rows = useLiveQuery( () => db.select().from(todos).where(eq(todos.userId, userId)), [userId],)Initial render returns an empty array; the first live delivery arrives
as soon as the async engine settles. If that flicker is a UX issue for
you, wrap the caller in Suspense-friendly branching yourself.
Type Parameters
Section titled “Type Parameters”TRow
Parameters
Section titled “Parameters”queryFactory
Section titled “queryFactory”() => LivableQuery<TRow>
DependencyList
Returns
Section titled “Returns”TRow[]