{"record":{"id":"6be35ce3a4346f44","repo":"marmelab/react-admin","slug":"useshowcontroller-requires-an-id-prop-or-a-route-w","errorCode":null,"errorMessage":"useShowController requires an id prop or a route with an /:id? parameter.","messagePattern":"useShowController requires an id prop or a route with an /:id\\? parameter\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/controller/show/useShowController.ts","lineNumber":84,"sourceCode":"    }\n\n    const { isPending: isPendingAuthenticated } = useAuthenticated({\n        enabled: !disableAuthentication,\n    });\n\n    const { isPending: isPendingCanAccess } = useRequireAccess<RecordType>({\n        action: 'show',\n        resource,\n        enabled: !disableAuthentication && !isPendingAuthenticated,\n    });\n\n    const getRecordRepresentation = useGetRecordRepresentation(resource);\n    const translate = useTranslate();\n    const notify = useNotify();\n    const redirect = useRedirect();\n    const { id: routeId } = useParams<{ id?: string }>();\n    if (!routeId && !propsId) {\n        throw new Error(\n            'useShowController requires an id prop or a route with an /:id? parameter.'\n        );\n    }\n    const id = propsId != null ? propsId : routeId;\n    const { meta, ...otherQueryOptions } = queryOptions;\n\n    const {\n        data: record,\n        error,\n        isLoading,\n        isFetching,\n        isPaused,\n        isPending,\n        isPlaceholderData,\n        refetch,\n    } = useGetOne<RecordType, ErrorType>(\n        resource,\n        { id, meta },","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/controller/show/useShowController.ts#L66-L102","documentation":"useShowController is react-admin's internal hook powering the Show view. It needs to know which record to display: either an explicit `id` prop or an `:id` route parameter. If neither is present it throws because a show view is meaningless without a record id.","triggerScenarios":"Calling useShowController() (or <Show>) without an id prop while the current route has no /:id? parameter (e.g. rendering a Show view at a path like /posts/show without :id, or calling the hook directly in a component not routed with an id param).","commonSituations":"Custom Show pages placed on a route that forgot the :id segment; copying <Show> into a dashboard/widget outside the resource routes; calling useShowController directly in a test without id; upgrading from a version that defaulted id differently.","solutions":["Pass an explicit id: <Show id={123}> or useShowController({ resource: 'posts', id: 123 })","Fix the route so it includes /:id, e.g. <Route path=\"posts/:id/show\" ...> or Resource's default show route","If the component is not tied to one record, use useListController or a custom query instead of the show controller"],"exampleFix":"// before\n<Route path=\"/posts/show\" element={<PostShow />} /> // no :id\n// after\n<Route path=\"/posts/:id/show\" element={<PostShow />} />","handlingStrategy":"validation","validationCode":"const { id: routeId } = useParams<{ id?: string }>();\nif (!routeId && !propsId) throw new Error('Show view requires an id');","typeGuard":"const hasId = (p: { id?: Identifier }) => p.id != null;","tryCatchPattern":"null","preventionTips":["Always route Show views with /:id","Pass id explicitly when reusing <Show> outside its default route","Add a test that mounts the Show view at its actual route"],"tags":["react-admin","missing-prop","routing"],"backgroundTag":"missing-required-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}