{"record":{"id":"471da470a4a5325b","repo":"marmelab/react-admin","slug":"uselistcontroller-requires-a-non-empty-resource-pr","errorCode":null,"errorMessage":"useListController requires a non-empty resource prop or context","messagePattern":"useListController requires a non-empty resource prop or context","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/controller/list/useListController.ts","lineNumber":69,"sourceCode":"    props: ListControllerProps<RecordType, ErrorType> = {}\n): ListControllerResult<RecordType, ErrorType> => {\n    const {\n        debounce = 500,\n        disableAuthentication = false,\n        disableSyncWithLocation = false,\n        exporter = defaultExporter,\n        filter,\n        filterDefaultValues,\n        perPage = 10,\n        queryOptions = {},\n        sort = defaultSort,\n        storeKey,\n    } = props;\n    const resource = useResourceContext(props);\n    const { meta, ...otherQueryOptions } = queryOptions;\n\n    if (!resource) {\n        throw new Error(\n            `useListController requires a non-empty resource prop or context`\n        );\n    }\n    if (\n        filter &&\n        (isValidElement(filter) ||\n            (Array.isArray(filter) && filter.some(isValidElement)))\n    ) {\n        throw new Error(\n            'useListController received a React element as `filter` props. If you intended to set the list filter elements, use the `filters` (with an s) prop instead. The `filter` prop is internal and should not be set by the developer.'\n        );\n    }\n\n    const { isPending: isPendingAuthenticated } = useAuthenticated({\n        enabled: !disableAuthentication,\n    });\n\n    const { isPending: isPendingCanAccess } = useRequireAccess<RecordType>({","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/controller/list/useListController.ts#L51-L87","documentation":"useListController (backing <List>) resolves the resource name from a `resource` prop or ResourceContext. If neither yields a non-empty string, it throws because it cannot build the dataProvider call.","triggerScenarios":"Rendering <List> outside a <Resource> without `resource` prop; passing resource={undefined} (e.g. from a missing route param); empty string resource.","commonSituations":"Custom pages using List directly; dynamic routes where :resource is missing; renaming resources and forgetting a prop; storybook/tests without ResourceContext.","solutions":["Pass resource explicitly: <List resource=\"posts\">","Ensure the component is rendered within a <Resource name=\"posts\"> context","Fix the route/param that supplies a dynamic resource name","Guard rendering: only render <List> when resource is truthy"],"exampleFix":"// before\nexport const MyListView = () => <List />;\n// after\nexport const MyListView = () => <List resource=\"posts\" />;\n// or guard\nif (!resource) return null;","handlingStrategy":"validation","validationCode":"const resource = props.resource ?? useResourceContext();\nif (!resource) throw new Error('useListController needs a resource');\nreturn <List resource={resource} />;","typeGuard":"const hasResource = (p: { resource?: string }): p is { resource: string } =>\n  typeof p.resource === 'string' && p.resource.length > 0;","tryCatchPattern":"try { return <List resource={maybeResource} />; } catch (e) { if (String(e).includes('non-empty resource')) { return <EmptyState />; } }","preventionTips":["Pass resource explicitly on custom pages","Validate route params before rendering list pages","Add ResourceContextProvider in tests/stories","Search codebase for bare `<List />` usages"],"tags":["react-admin","missing-props","context"],"backgroundTag":"missing-resource-context","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}