{"record":{"id":"8411c154c223732c","repo":"marmelab/react-admin","slug":"translatablefields-was-called-outside-of-a-recor","errorCode":null,"errorMessage":"<TranslatableFields> was called outside of a RecordContext and without a record prop. You must set the record prop.","messagePattern":"<TranslatableFields> was called outside of a RecordContext and without a record prop\\. You must set the record prop\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/field/TranslatableFields.tsx","lineNumber":89,"sourceCode":" * @param {ReactElement} props.selector The element responsible for selecting a locale. Defaults to Material UI tabs.\n */\nexport const TranslatableFields = (inProps: TranslatableFieldsProps) => {\n    const props = useThemeProps({\n        props: inProps,\n        name: PREFIX,\n    });\n    const {\n        defaultLocale,\n        locales,\n        groupKey = '',\n        selector = <TranslatableFieldsTabs groupKey={groupKey} />,\n        children,\n        className,\n        resource: resourceProp,\n    } = props;\n    const record = useRecordContext(props);\n    if (!record) {\n        throw new Error(\n            `<TranslatableFields> was called outside of a RecordContext and without a record prop. You must set the record prop.`\n        );\n    }\n    const resource = useResourceContext(props);\n    if (!resource) {\n        throw new Error(\n            `<TranslatableFields> was called outside of a ResourceContext and without a record prop. You must set the resource prop.`\n        );\n    }\n    const context = useTranslatable({ defaultLocale, locales });\n\n    return (\n        <Root className={className}>\n            <TranslatableContextProvider value={context}>\n                {selector}\n                {locales.map(locale => (\n                    <TranslatableFieldsTabContent\n                        key={locale}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/field/TranslatableFields.tsx#L71-L107","documentation":"<TranslatableFields> renders its children for each locale of the current record; without a record there is no data to translate, so it throws. The record normally comes from RecordContext (provided by Show/Edit/RecordContextProvider) or an explicit `record` prop.","triggerScenarios":"Rendering <TranslatableFields> outside a RecordContext (not inside <Show>/<Edit>/List row) and without a `record` prop; useRecordContext(props) returns undefined.","commonSituations":"Using TranslatableFields in a custom page or create form where no record exists yet; rendering it in isolation in a story/test; placing it outside the Show/Edit layout that supplies the record.","solutions":["Wrap it in a RecordContextProvider or render inside <Show>/<Edit>: `<RecordContextProvider value={record}><TranslatableFields locales={[...]}>...</TranslatableFields></RecordContextProvider>`.","Pass a `record` prop explicitly: `<TranslatableFields record={myRecord} locales={...}>`.","If there is no record yet (create), guard rendering until a record is available."],"exampleFix":"// before\n<TranslatableFields locales={['en', 'fr']}>\n  <TextField source=\"title\" />\n</TranslatableFields>\n\n// after\n<RecordContextProvider value={record}>\n  <TranslatableFields locales={['en', 'fr']}>\n    <TextField source=\"title\" />\n  </TranslatableFields>\n</RecordContextProvider>","handlingStrategy":"validation","validationCode":"if (!record) return null; // or render a placeholder before mounting TranslatableFields","typeGuard":"const hasRecord = (p: { record?: RaRecord }): p is typeof p & { record: RaRecord } => p.record != null;","tryCatchPattern":null,"preventionTips":["Render TranslatableFields only inside <Show>/<Edit> or RecordContextProvider.","Guard custom pages so they render once the record has loaded."],"tags":["react-admin","translatable-fields","record-context","i18n"],"backgroundTag":"missing-context-provider","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}