{"record":{"id":"d723951c6abb7914","repo":"marmelab/react-admin","slug":"you-can-only-provide-one-function-child-to-adminro","errorCode":null,"errorMessage":"You can only provide one function child to AdminRouter","messagePattern":"You can only provide one function child to AdminRouter","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/core/useConfigureAdminRouterFromChildren.tsx","lineNumber":279,"sourceCode":"          : 'empty';\n};\n\n/**\n * Inspect the children of a CoreAdminRouter to see if one of them is a function.\n * Throws an error if there are more than one function child.\n * Returns the function child if one was provided, or null otherwise.\n */\nconst getSingleChildFunction = (\n    children: AdminChildren\n): RenderResourcesFunction | null => {\n    const childrenArray = Array.isArray(children) ? children : [children];\n\n    const functionChildren = childrenArray.filter(\n        child => typeof child === 'function'\n    );\n\n    if (functionChildren.length > 1) {\n        throw new Error(\n            'You can only provide one function child to AdminRouter'\n        );\n    }\n\n    if (functionChildren.length === 0) {\n        return null;\n    }\n\n    return functionChildren[0] as RenderResourcesFunction;\n};\n\n/**\n * Inspect the children and return an object with the following keys:\n * - customRoutesWithLayout: an array of the custom routes to render inside the layout\n * - customRoutesWithoutLayout: an array of custom routes to render outside the layout\n * - resources: an array of resources elements\n */\nconst getRoutesAndResourceFromNodes = (","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/core/useConfigureAdminRouterFromChildren.tsx#L261-L297","documentation":"<AdminRouter> (and <Admin>) accepts at most one render-prop / function child, used to derive the UI from permissions. When more than one child of the children array is a function, the configuration is ambiguous and getSingleChildFunction throws.","triggerScenarios":"Writing `<AdminRouter>{perms => ...}{perms => ...}</AdminRouter>` — two function children; spreading an array of children where several are functions, e.g. `{[renderA, renderB]}`; accidentally passing an inline arrow plus a function variable as siblings.","commonSituations":"Copy-pasting permission-based render props; composing Admin children programmatically from arrays without filtering functions; JSX confusion between mixing component children and one render prop.","solutions":["Keep exactly one function child: merge the logic of both functions into a single render prop","Wrap additional functions in real components (e.g. () => <CustomRoutes ... /> becomes <CustomRoutes />) or move them inside the single function child","Log/inspect the children array when building it dynamically to ensure only one function remains"],"exampleFix":"// before\n<AdminRouter>\n  {permissions => <Menu permissions={permissions} />}\n  {permissions => <Dashboard permissions={permissions} />}\n</AdminRouter>\n\n// after\n<AdminRouter>\n  {permissions => (\n    <>\n      <Menu permissions={permissions} />\n      <Dashboard permissions={permissions} />\n    </>\n  )}\n</AdminRouter>","handlingStrategy":"validation","validationCode":"const fns = React.Children.toArray(children).filter(c => typeof c === 'function');\nif (fns.length > 1) throw new Error('AdminRouter accepts at most one function child');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a single render-prop child for permission-based UI","Never spread arrays of render props into <Admin> children","Convert helper functions to components when composing children","Lint JSX for multiple arrow-function children inside Admin/AdminRouter"],"tags":["react-admin","children-validation","render-prop","configuration"],"backgroundTag":"multiple-function-children","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}