{"record":{"id":"5e3c44b1c96d4afd","repo":"marmelab/react-admin","slug":"list-requires-either-a-render-prop-or-childre","errorCode":null,"errorMessage":"<List> requires either a `render` prop or `children` prop","messagePattern":"<List> requires either a `render` prop or `children` prop","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/list/List.tsx","lineNumber":84,"sourceCode":"        exporter,\n        filter = defaultFilter,\n        filterDefaultValues,\n        authLoading = defaultAuthLoading,\n        loading,\n        perPage = 10,\n        queryOptions,\n        resource,\n        sort,\n        storeKey,\n        render,\n        ...rest\n    } = useThemeProps({\n        props: props,\n        name: PREFIX,\n    });\n\n    if (!props.render && !props.children) {\n        throw new Error(\n            '<List> requires either a `render` prop or `children` prop'\n        );\n    }\n\n    return (\n        <ListBase<RecordType>\n            debounce={debounce}\n            disableAuthentication={disableAuthentication}\n            disableSyncWithLocation={disableSyncWithLocation}\n            exporter={exporter}\n            filter={filter}\n            filterDefaultValues={filterDefaultValues}\n            authLoading={authLoading}\n            loading={loading}\n            perPage={perPage}\n            queryOptions={queryOptions}\n            resource={resource}\n            sort={sort}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/list/List.tsx#L66-L102","documentation":"react-admin's <List> component must know what to render for the list body. Since the render-prop refactor, it accepts either a `render` function (receiving ListContext) or classic `children` (e.g. a <Datagrid>). The component explicitly throws in its setup code when neither prop is supplied, because rendering it would otherwise produce an empty, unusable list.","triggerScenarios":"Rendering <List> with no `render` prop and no children, e.g. `<List></></List>` empty, or `<List {...listProps} />` where a spread accidentally omits both render and children.","commonSituations":"Migrating from older react-admin examples that passed children, then removing the child during refactoring; conditionally rendering children like `{showGrid && <Datagrid/>}` which evaluates to no children when false; spreading props that lost the render callback.","solutions":["Pass a `render` prop: `<List render={({ filterValues }) => <Datagrid/>} />`.","Or pass children directly: `<List><Datagrid /></List>`.","If children are conditional, ensure at least one is always rendered or guard the whole <List> render instead."],"exampleFix":"// before\n<List>\n  {hasColumns && <Datagrid>{columns}</Datagrid>}\n</List>\n// after\n<List>\n  <Datagrid>{columns}</Datagrid>\n</List>","handlingStrategy":"validation","validationCode":"if (!render && !children) {\n  throw new Error('<List> requires either a `render` prop or `children` prop');\n}\n// or simply: <List>{children ?? <Datagrid />}</List>","typeGuard":"const hasListBody = (p: { render?: unknown; children?: unknown }): p is { render?: Function; children: React.ReactNode } =>\n  typeof p.render === 'function' || React.Children.count(p.children) > 0;","tryCatchPattern":null,"preventionTips":["Always give <List> a Datagrid (or SimpleList) child or a render callback.","Avoid conditional-only children inside <List>; move conditionals inside the render/body component.","Add a shared ListWrapper component that guarantees a default body."],"tags":["react-admin","list","missing-prop","render-props"],"backgroundTag":"missing-required-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}