marmelab/react-admin · error

Status should be defined

Error message

Status should be defined

What it means

useRoutesAndResourcesFromChildren (internal hook powering <Admin>'s route/resource resolution) computes a `status` from its children ('empty', 'loading', 'configuring'...). getStatus is expected to always yield a status; if it somehow returns undefined, this defensive error is thrown. It indicates the status computation returned nothing valid.

Source

Thrown at packages/ra-core/src/core/useConfigureAdminRouterFromChildren.tsx:92

    permissions: any,
    isLoading: boolean
): [RoutesAndResources, AdminRouterStatus] => {
    // Gather custom routes and resources that were declared as direct children of CoreAdminRouter
    // e.g. Not returned from the child function (if any)
    // We need to know right away whether some resources were declared to correctly
    // initialize the status at the next stop
    const doLogout = useLogout();
    const [routesAndResources, setRoutesAndResources, mergeRoutesAndResources] =
        useRoutesAndResourcesState(getRoutesAndResourceFromNodes(children));

    const [status, setStatus] = useState<AdminRouterStatus>(() =>
        getStatus({
            children,
            ...routesAndResources,
        })
    );
    if (!status) {
        throw new Error('Status should be defined');
    }

    useEffect(() => {
        const resolveChildFunction = async (
            childFunc: RenderResourcesFunction
        ) => {
            try {
                const childrenFuncResult = childFunc(permissions);
                if ((childrenFuncResult as Promise<ReactNode>)?.then) {
                    (childrenFuncResult as Promise<ReactNode>).then(
                        resolvedChildren => {
                            mergeRoutesAndResources(
                                getRoutesAndResourceFromNodes(resolvedChildren)
                            );
                            setStatus('ready');
                        }
                    );
                } else {

View on GitHub (pinned to 051f511bb0)

Solutions

  1. Only pass <Resource>, <CustomRoutes>, or function-returning-these as <Admin> children
  2. If building a custom admin with this internal hook, ensure getStatus inputs (children + routesAndResources) match the documented shapes
  3. Upgrade or align versions of ra-core packages so getStatus and the hook come from the same version

Example fix

// before
<Admin dataProvider={dp}>Some text</Admin>
// after
<Admin dataProvider={dp}>
  <Resource name="posts" list={PostList} />
</Admin>
Defensive patterns

Strategy: validation

Validate before calling

// Ensure only valid children are passed to <Admin>
const isValidAdminChild = (child) =>
  isValidElement(child) &&
  [Resource.displayName, CustomRoutes.displayName].includes(child.type?.displayName ?? child.type?.name);

Type guard

import { isValidElement } from 'react';
const isAdminChild = (child) => isValidElement(child) && (child.type === Resource || child.type === CustomRoutes);

Prevention

When it happens

Trigger: An edge case in getStatus where the children/routesAndResources combination yields no known status — e.g. an unexpected child type passed to <Admin> (a function child or raw string), or a race where routesAndResources are being computed asynchronously and return an unhandled shape. As a defensive invariant it is rare and usually signals passing unusual children.

Common situations: Passing non-Resource/non-CustomRoutes children (strings, functions, arrays with unexpected elements) directly to <Admin>; using the internal hook directly in a custom admin composition; version mismatches where getStatus logic changed.

Related errors


AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30). Data as JSON: /api/errors/1277e18048ce3049. Report an issue: GitHub.