{"record":{"id":"f09fa5185f78c0f6","repo":"marmelab/react-admin","slug":"simpleformiteratoritem-must-be-used-in-a-recordcon","errorCode":null,"errorMessage":"SimpleFormIteratorItem must be used in a RecordContextProvider.","messagePattern":"SimpleFormIteratorItem must be used in a RecordContextProvider\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/input/ArrayInput/SimpleFormIteratorItem.tsx","lineNumber":34,"sourceCode":"\nexport const SimpleFormIteratorItem = memo(\n    forwardRef<HTMLLIElement, SimpleFormIteratorItemProps>(\n        function SimpleFormIteratorItem(props, ref) {\n            const {\n                children,\n                disabled,\n                disableReordering,\n                disableRemove,\n                getItemLabel,\n                index,\n                inline,\n                removeButton = <DefaultRemoveItemButton />,\n                reOrderButtons = <DefaultReOrderButtons />,\n            } = props;\n\n            const record = useRecordContext(props);\n            if (!record) {\n                throw new Error(\n                    'SimpleFormIteratorItem must be used in a RecordContextProvider.'\n                );\n            }\n\n            // Returns a boolean to indicate whether to disable the remove button for certain fields.\n            // If disableRemove is a function, then call the function with the current record to\n            // determining if the button should be disabled. Otherwise, use a boolean property that\n            // enables or disables the button for all of the fields.\n            const disableRemoveField = (record: RaRecord) => {\n                if (typeof disableRemove === 'boolean') {\n                    return disableRemove;\n                }\n                return disableRemove && disableRemove(record);\n            };\n\n            const label =\n                typeof getItemLabel === 'function'\n                    ? getItemLabel(index)","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/input/ArrayInput/SimpleFormIteratorItem.tsx#L16-L52","documentation":"<SimpleFormIteratorItem> represents one row of an array input and reads that row's record from RecordContext. If no record is provided via RecordContextProvider, the row has no data to operate on, so it throws.","triggerScenarios":"Rendering <SimpleFormIteratorItem> manually without wrapping it in <RecordContextProvider value={record}>; using a custom iterator body that renders items directly instead of through SimpleFormIterator.","commonSituations":"Building a custom array iterator that reuses SimpleFormIteratorItem but forgets to supply the per-item record context; customizing SimpleFormIterator by cloning its internals.","solutions":["Wrap each item in a RecordContextProvider: `<RecordContextProvider value={record}><SimpleFormIteratorItem ... /></RecordContextProvider>`.","Render items through <SimpleFormIterator>, which supplies the record context automatically.","If building a custom iterator, provide the item's record (fields value + index) to the context."],"exampleFix":"// before\n<SimpleFormIteratorItem index={i} removeButton={...} />\n\n// after\n<RecordContextProvider value={record}>\n  <SimpleFormIteratorItem index={i} removeButton={...} />\n</RecordContextProvider>","handlingStrategy":"validation","validationCode":"if (!record) return null; // skip rendering item until RecordContext is available","typeGuard":"const hasItemRecord = (p: { record?: RaRecord }): p is typeof p & { record: RaRecord } => p.record != null;","tryCatchPattern":null,"preventionTips":["Render items via SimpleFormIterator rather than manually.","When composing custom iterators, always wrap each item in RecordContextProvider with the row record."],"tags":["react-admin","record-context","simpleformiterator","invalid-usage"],"backgroundTag":"missing-context-provider","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}