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-fieldFetches the first related record with getManyReference (a page of one) and renders its fields.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Child field(s) rendered against the referenced record. |
| empty | ReactNode | — | Rendered when no related record exists. A string is translated. |
| error | ReactNode | — | Rendered when the reference lookup errors. |
| filter | FilterPayload | — | Permanent filter merged into the reference lookup. Read when the record id changes; remount with a `key` to change it otherwise. |
| loading | ReactNode | — | Rendered while the referenced record is loading. |
| record | RecordType | — | The record whose id is matched. Defaults to the ambient record. |
| reference | string | — | 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). |
| sort | SortPayload | — | 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. |
| source | string | — | The field on the current record the `target` matches. Default `"id"`. |
| target | string | — | The FK field on the reference pointing back at this record (e.g. `"author_id"`). |