{"record":{"id":"228e073a0ac32c61","repo":"marmelab/react-admin","slug":"label-parameter-must-be-a-string-a-reactelement-o","errorCode":null,"errorMessage":"Label parameter must be a string, a ReactElement or false","messagePattern":"Label parameter must be a string, a ReactElement or false","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/util/FieldTitle.tsx","lineNumber":18,"sourceCode":"import * as React from 'react';\nimport { ReactNode, memo } from 'react';\n\nimport { useTranslateLabel } from '../i18n';\n\nexport interface FieldTitleProps {\n    isRequired?: boolean;\n    resource?: string;\n    source?: string;\n    label?: ReactNode;\n}\n\nexport const FieldTitle = (props: FieldTitleProps) => {\n    const { source, label, resource, isRequired } = props;\n    const translateLabel = useTranslateLabel();\n\n    if (label === true) {\n        throw new Error(\n            'Label parameter must be a string, a ReactElement or false'\n        );\n    }\n\n    if (label === false || label === '') {\n        return null;\n    }\n\n    if (label != null && typeof label !== 'string') {\n        return label;\n    }\n\n    return (\n        <span>\n            {translateLabel({\n                label,\n                resource,\n                source,","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/util/FieldTitle.tsx#L1-L36","documentation":"FieldTitle computes a field's label from the label/source props and translation. The `label` prop may be a string, a ReactElement, or false; passing `true` is invalid because there is no meaningful rendering for a boolean true label, so it throws immediately.","triggerScenarios":"Passing label={true} (or a variable evaluating to true) to an input or field such as <TextInput source=\"x\" label={true} />; spreading props where label came from untyped config/JSON containing true; TypeScript bypassed with `any` so the union type didn't catch it.","commonSituations":"Dynamic label configuration from backend/CMS values; conditional label logic like label={someCondition} that resolves to a boolean; migrating code where label was previously optional and someone used true as 'show label'.","solutions":["Remove the label prop entirely to use the default (translated from source)","Pass a concrete string: label=\"My label\" or a translation element <label={<Translate i18nKey=\"...\" />} />","Pass label={false} to hide the label","Fix the upstream value so booleans never reach label (coerce at the config boundary)"],"exampleFix":"// before\n<TextInput source=\"name\" label={showLabel} />\n\n// after\n<TextInput source=\"name\" label={showLabel ? 'Name' : false} />","handlingStrategy":"validation","validationCode":"const VALID = (v) => v === false || typeof v === 'string' || React.isValidElement(v) || v == null;\nif (label != null && !VALID(label)) throw new Error('label must be string, element, or false');","typeGuard":"const isValidLabel = (label: unknown): label is string | React.ReactElement | false | undefined =>\n  label === false || label === undefined || typeof label === 'string' || React.isValidElement(label);","tryCatchPattern":"try {\n  setLabel(config.label);\n} catch (e) {\n  if (e.message.includes('Label parameter must be')) {\n    setLabel(undefined); // fall back to default label\n  } else throw e;\n}","preventionTips":["Type label as ReactElement | string | false in your config schemas","Never pass raw booleans other than false as label","Sanitize backend/CMS label config before mapping to input props","Use the FieldTitleProps type so TS rejects label={true}"],"tags":["react-admin","field-title","invalid-prop","validation"],"backgroundTag":"invalid-label-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}