{"record":{"id":"120b4f809e10987c","repo":"marmelab/react-admin","slug":"referencefieldbase-requires-either-a-render-pr","errorCode":null,"errorMessage":"<ReferenceFieldBase> requires either a 'render' prop or 'children' prop","messagePattern":"<ReferenceFieldBase> requires either a 'render' prop or 'children' prop","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/controller/field/ReferenceFieldBase.tsx","lineNumber":57,"sourceCode":" * <ReferenceFieldBase source=\"userId\" reference=\"users\" link={(record, reference) => \"/path/to/${reference}/${record}\"} />\n *\n * @default\n * In previous versions of React-Admin, the prop `linkType` was used. It is now deprecated and replaced with `link`. However\n * backward-compatibility is still kept\n */\nexport const ReferenceFieldBase = <\n    ReferenceRecordType extends RaRecord = RaRecord,\n>(\n    props: ReferenceFieldBaseProps<ReferenceRecordType>\n) => {\n    const { children, render, loading, error, empty, offline } = props;\n    const id = useFieldValue(props);\n\n    const controllerProps =\n        useReferenceFieldController<ReferenceRecordType>(props);\n\n    if (!render && !children) {\n        throw new Error(\n            \"<ReferenceFieldBase> requires either a 'render' prop or 'children' prop\"\n        );\n    }\n\n    const {\n        error: controllerError,\n        isPending,\n        isPaused,\n        referenceRecord,\n    } = controllerProps;\n    const shouldRenderLoading =\n        id != null &&\n        !isPaused &&\n        isPending &&\n        loading !== false &&\n        loading !== undefined;\n    const shouldRenderOffline =\n        isPaused && isPending && offline !== false && offline !== undefined;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/controller/field/ReferenceFieldBase.tsx#L39-L75","documentation":"ReferenceFieldBase is the headless core of <ReferenceField>; it must be told how to render the resolved reference record via a render prop or children. When neither is present the component would render nothing, so react-admin throws immediately during render.","triggerScenarios":"Using <ReferenceFieldBase source=\"user_id\" reference=\"users\" /> without render or children; passing children that evaluate to undefined (conditional JSX, a variable that is null); forgetting the child when migrating from an older field API.","commonSituations":"Building a custom field on top of the headless base component and forgetting the render layer; dynamic children like {enabled && <Child/>} that resolve to false; copying ra-ui-materialist <ReferenceField> usage but calling the ra-core base directly.","solutions":["Add children: <ReferenceFieldBase source=\"user_id\" reference=\"users\"><TextField source=\"name\" /></ReferenceFieldBase>","Or add a render prop: <ReferenceFieldBase source=\"user_id\" reference=\"users\" render={({referenceRecord}) => ...} />","Verify the children expression is truthy at runtime when it is conditional"],"exampleFix":"// before\n<ReferenceFieldBase source=\"user_id\" reference=\"users\" />\n// after\n<ReferenceFieldBase source=\"user_id\" reference=\"users\">\n  <TextField source=\"name\" />\n</ReferenceFieldBase>","handlingStrategy":"validation","validationCode":"const assertRenderable = (p: { render?: unknown; children?: unknown }) => {\n  if (p.render == null && p.children == null)\n    throw new Error('Provide render or children');\n};","typeGuard":"const canRender = (p: { render?: unknown; children?: unknown }): boolean =>\n  Boolean(p.render ?? p.children);","tryCatchPattern":"try {\n  render(<ReferenceFieldBase source=\"user_id\" reference=\"users\" />);\n} catch (e) { logAndFallback(e); }","preventionTips":["Always supply children or render","Avoid falsy conditional children","Prefer UI-kit <ReferenceField>","Smoke-test custom fields"],"tags":["react-admin","props-validation","reference-field","render-prop"],"backgroundTag":"missing-required-render-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}