marmelab/react-admin · error

<Create> requires either a `render` prop or `children` prop

Error message

<Create> requires either a `render` prop or `children` prop

What it means

The <Create> view must know what to render. It requires either a `render` function prop or `children` elements; receiving neither is a programming mistake, so the library throws immediately at render. This enforces the newer declarative render API over empty usage.

Source

Thrown at packages/ra-ui-materialui/src/detail/Create.tsx:80

    });

    const {
        resource,
        record,
        redirect,
        transform,
        mutationMode,
        mutationOptions,
        disableAuthentication,
        hasEdit,
        hasShow,
        loading,
        authLoading = loading ?? defaultAuthLoading,
        ...rest
    } = props;

    if (!props.render && !props.children) {
        throw new Error(
            '<Create> requires either a `render` prop or `children` prop'
        );
    }

    return (
        <CreateBase<RecordType, ResultRecordType>
            resource={resource}
            record={record}
            redirect={redirect}
            transform={transform}
            mutationMode={mutationMode}
            mutationOptions={mutationOptions}
            disableAuthentication={disableAuthentication}
            hasEdit={hasEdit}
            hasShow={hasShow}
            authLoading={authLoading}
        >
            <CreateView {...rest} />

View on GitHub (pinned to 051f511bb0)

Solutions

  1. Pass children: <Create resource="posts"><SimpleForm>...</SimpleForm></Create>
  2. Or pass a render function: <Create resource="posts" render={() => <SimpleForm>...</SimpleForm>} />
  3. Check conditional logic so children/render is never undefined

Example fix

// before
<Create resource="posts" />
// after
<Create resource="posts">
  <SimpleForm><TextInput source="title" /></SimpleForm>
</Create>
Defensive patterns

Strategy: validation

Validate before calling

if (!props.children && !props.render) {
  throw new Error('<Create> requires a render prop or children');
}
ReactDOM.createRoot(el).render(<Create resource="posts"><SimpleForm>...</SimpleForm></Create>);

Type guard

const hasContent = (p: { children?: React.ReactNode; render?: () => React.ReactNode }): boolean =>
  p.render != null || React.Children.count(p.children) > 0;

Prevention

When it happens

Trigger: Rendering <Create resource="posts"> with no children and no render prop; passing children conditionally such that both end up undefined (e.g. children={maybeUndefined}).

Common situations: Upgrading react-admin and replacing old `<Create><CreateForm/></Create>` incorrectly; copying a skeleton snippet; conditional rendering logic that drops all children.

Related errors


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