Skip to main content

Function: useField()

useField(id, options): UseQueryResult<any, Error>

Defined in: web/lib/hooks/use-field.ts:73

Fetches a single field by ID with optional relationships.

Parameters

id

string

The field ID

options

UseFieldOptions = {}

Query and data options

Returns

UseQueryResult<any, Error>

Query result with field data, loading state, and error

Remarks

Uses TanStack Query with a 6-hour stale time. Fields change infrequently so aggressive caching is appropriate.

Example

const { data, isLoading, error } = useField('computer-science', {
includeChildren: true,
includeAncestors: true,
});