{"record":{"id":"cc733086980082e8","repo":"marmelab/react-admin","slug":"datagridrow-expects-an-id-prop","errorCode":null,"errorMessage":"DatagridRow expects an id prop","messagePattern":"DatagridRow expects an id prop","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx","lineNumber":60,"sourceCode":"> = React.forwardRef<HTMLTableRowElement, DatagridRowProps>((props, ref) => {\n    const {\n        children,\n        className,\n        expand,\n        hasBulkActions = false,\n        hover = true,\n        id,\n        onToggleItem,\n        record: recordOverride,\n        rowClick,\n        selected = false,\n        style,\n        selectable = true,\n        ...rest\n    } = props;\n\n    if (typeof id === 'undefined') {\n        throw new Error('DatagridRow expects an id prop');\n    }\n    const context = useDatagridContext();\n    const translate = useTranslate();\n    const record = useRecordContext(props);\n    if (!record) {\n        throw new Error(\n            'DatagridRow 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            'DatagridRow can only be used within a ResourceContext or be passed a resource prop'\n        );\n    }","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx#L42-L78","documentation":"Inside <Datagrid>, each row (DatagridRow) needs the record id to build selection state, row click handlers, and expansion keys. The expand-content variant of DatagridRow destructures `id` from props and throws immediately when it is undefined, since rows without ids cannot participate in the datagrid's row identity logic.","triggerScenarios":"Rendering a custom row component (row via `<Datagrid row={...}>` or expand panel) that does not forward the `id` prop down to DatagridRow, or using DatagridRow directly without an id.","commonSituations":"Wrapping DatagridRow in a custom component that filters out unknown props (including id); building a custom expand renderer and forgetting `{...props}` passthrough; TypeScript not catching it because props were spread loosely.","solutions":["Forward all row props to DatagridRow, including id: `<DatagridRow {...props} />`.","When using DatagridRow directly, pass `id={record.id}`.","In custom wrappers, explicitly destructure and re-pass `id`."],"exampleFix":"// before\nconst MyRow = ({ id, ...rest }) => <DatagridRow {...rest} />;\n// after\nconst MyRow = (props) => <DatagridRow {...props} />;","handlingStrategy":"type-guard","validationCode":"rows.forEach(r => { if (r.id == null) throw new Error('dataProvider returned a row without id'); });","typeGuard":"const hasId = (r: Record<string, unknown> & { id?: unknown }): r is { id: Identifier } =>\n  r.id !== undefined && r.id !== null;","tryCatchPattern":null,"preventionTips":["Always spread {...props} from custom row wrappers into DatagridRow.","Ensure the dataProvider normalizes every record to have an `id`.","Add a dev-time assertion that mapped records contain ids."],"tags":["react-admin","datagrid","missing-prop","row"],"backgroundTag":"missing-required-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}