{"record":{"id":"3e2e8bc742c987b9","repo":"marmelab/react-admin","slug":"infinitelist-was-called-outside-of-a-resourcecon","errorCode":null,"errorMessage":"<InfiniteList> was called outside of a ResourceContext and without a resource prop. You must set the resource prop.","messagePattern":"<InfiniteList> was called outside of a ResourceContext and without a resource prop\\. You must set the resource prop\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/controller/list/useInfiniteListController.ts","lineNumber":66,"sourceCode":"    props: InfiniteListControllerProps<RecordType, ErrorType> = {}\n): InfiniteListControllerResult<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,\n        storeKey,\n    } = props;\n    const resource = useResourceContext(props);\n    const { meta, ...otherQueryOptions } = queryOptions ?? {};\n\n    if (!resource) {\n        throw new Error(\n            `<InfiniteList> was called outside of a ResourceContext and without a resource prop. You must set the resource prop.`\n        );\n    }\n    if (filter && isValidElement(filter)) {\n        throw new Error(\n            '<InfiniteList> 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>({\n        action: 'list',\n        resource,\n        enabled: !disableAuthentication && !isPendingAuthenticated,\n    });","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/controller/list/useInfiniteListController.ts#L48-L84","documentation":"<InfiniteList> and its controller hook need to know which resource to fetch. The library resolves the resource from a `resource` prop or the surrounding ResourceContext; if both are absent, useInfiniteListController throws. This guards against rendering an infinite list with no data source.","triggerScenarios":"Rendering <InfiniteList> outside a <Resource> context without passing a `resource` prop, e.g. on a custom page or in a story, or passing an empty/undefined resource.","commonSituations":"Custom pages and dashboards using InfiniteList directly; renaming resources so the prop became undefined; migrating from List (which had defaults) to InfiniteList.","solutions":["Pass an explicit `resource` prop: <InfiniteList resource=\"posts\" />","Render the InfiniteList inside a <Resource name=\"posts\"> route/context","Wrap the component in a <ResourceContextProvider value=\"posts\">","Check for typos/undefined variables in a dynamic resource prop"],"exampleFix":"// before\n<InfiniteList />\n// after\n<InfiniteList resource=\"posts\" />","handlingStrategy":"validation","validationCode":"const resource = props.resource ?? useResourceContext();\nif (!resource) throw new Error('<InfiniteList> needs a resource prop or ResourceContext');\nreturn <InfiniteList resource={resource} {...props} />;","typeGuard":"const hasResource = (p: { resource?: string }): p is { resource: string } =>\n  typeof p.resource === 'string' && p.resource.length > 0;","tryCatchPattern":"null","preventionTips":["Always render InfiniteList within a Resource route or pass resource explicitly","Add a runtime check in custom wrappers around list components","In tests, wrap with ResourceContextProvider value=\"posts\"","Never derive resource from possibly-undefined route params without a fallback"],"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"}