{"record":{"id":"fe88865b6d628bce","repo":"marmelab/react-admin","slug":"datatablerow-can-only-be-used-within-a-recordconte-fe8886","errorCode":null,"errorMessage":"DataTableRow can only be used within a RecordContext or be passed a record prop","messagePattern":"DataTableRow can only be used within a RecordContext or be passed a record prop","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/list/datatable/DataTableRow.tsx","lineNumber":62,"sourceCode":"    React.forwardRef<HTMLTableRowElement, DataTableRowProps>((inProps, ref) => {\n        const props = useThemeProps({\n            props: inProps,\n            name: PREFIX,\n        });\n        const { children, className, ...rest } = props;\n        const {\n            expand,\n            expandSingle,\n            hasBulkActions = false,\n            hover = true,\n        } = useDataTableConfigContext();\n\n        const { handleToggleItem, isRowExpandable, isRowSelectable, rowClick } =\n            useDataTableCallbacksContext();\n\n        const record = useRecordContext(props);\n        if (!record) {\n            throw new Error(\n                'DataTableRow can only be used within a RecordContext or be passed a record prop'\n            );\n        }\n        const resource = useResourceContext(props);\n        const resourceDefinition = useResourceDefinition(props);\n        const hasDetailView =\n            resourceDefinition.hasShow || resourceDefinition.hasEdit;\n        if (!resource) {\n            throw new Error(\n                'DataTableRow can only be used within a ResourceContext or be passed a resource prop'\n            );\n        }\n        const selectable = !isRowSelectable || isRowSelectable(record);\n        const expandable =\n            (!isRowExpandable || isRowExpandable(record)) && expand;\n        const [expanded, toggleExpanded] = useExpanded(\n            resource,\n            record.id,","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/list/datatable/DataTableRow.tsx#L44-L80","documentation":"DataTableRow reads the current record via useRecordContext(props) to render its cells and wire row callbacks (toggle, expand, rowClick). If no record is available from context and none is passed via props, it throws — a row without record data is meaningless.","triggerScenarios":"Rendering <DataTableRow> outside a <DataTable>/RecordContext without a `record` prop, or a custom row wrapper that fails to forward `record`.","commonSituations":"Reusing DataTableRow for consistent styling in an ordinary <table>; isolated rendering in tests/storybook; wrappers that destructure and drop the record prop.","solutions":["Render DataTableRow inside a <DataTable> so RecordContext provides the record.","Pass `record` explicitly: `<DataTableRow record={post}>...`.","Wrap with `<RecordContextProvider value={record}>` for manual composition."],"exampleFix":"// before\n<DataTableRow resource=\"posts\">...\n// after\n<DataTableRow record={post} resource=\"posts\">...","handlingStrategy":"type-guard","validationCode":"const record = useRecordContext(props);\nif (!record) return null; // guard before rendering DataTableRow","typeGuard":"const hasRecord = <T extends { record?: RaRecord }>(p: T): p is T & { record: RaRecord } =>\n  p.record !== undefined && p.record !== null;","tryCatchPattern":null,"preventionTips":["Use DataTableRow only inside <DataTable>, or pass record explicitly.","Wrap isolated usage in RecordContextProvider.","Avoid wrappers that strip the `record` prop before forwarding."],"tags":["react-admin","datatable","context","record-context"],"backgroundTag":"missing-provider-context","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}