ReferenceOneField

Fetches the first related record with getManyReference (a page of one) and renders its fields.

Installation

pnpm dlx shadcn@latest add @chelone/reference-one-field

Fetches the first related record with getManyReference (a page of one) and renders its fields.

Props

PropTypeDefaultDescription
childrenReactNode—Child field(s) rendered against the referenced record.
emptyReactNode—Rendered when no related record exists. A string is translated.
errorReactNode—Rendered when the reference lookup errors.
filterFilterPayload—Permanent filter merged into the reference lookup. Read when the record id changes; remount with a `key` to change it otherwise.
loadingReactNode—Rendered while the referenced record is loading.
recordRecordType—The record whose id is matched. Defaults to the ambient record.
referencestring—The referenced resource holding the one-to-one record (e.g. `"bios"`).
render(referenceRecord: UnknownRecord | undefined) => ReactNode—Render-prop alternative to `children`: receives the resolved referenced record (or `undefined` while loading / on error).
sortSortPayload—Sort applied to the reference lookup (the first match is used). Read when the record id changes; remount with a `key` to change it otherwise.
sourcestring—The field on the current record the `target` matches. Default `"id"`.
targetstring—The FK field on the reference pointing back at this record (e.g. `"author_id"`).