Skip to main content

useQbId()

useQbId(qbIdProp?: string): UseQbId

Defined in: packages/react-querybuilder/src/hooks/useQbId.ts:31

Manages the qbId for a QueryBuilder instance.

The qbId prop is only evaluated when the component mounts—changing it later logs an error (in non-production modes) and is otherwise ignored.

Collision detection deliberately happens in an effect (see resolveQbIdCollision) rather than during render. The instance registry only reflects committed query builders, and when a query builder is unmounted and remounted with the same qbId in a single commit, the outgoing instance is still registered while the incoming one renders. Checking during render would flag that legitimate pattern as a collision; by the time effects run, React has already flushed the outgoing instance's cleanup, so the count is accurate.

Parameters

ParameterType
qbIdProp?string

Returns

UseQbId


caution

API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.