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
- Pass children: <Create resource="posts"><SimpleForm>...</SimpleForm></Create>
- Or pass a render function: <Create resource="posts" render={() => <SimpleForm>...</SimpleForm>} />
- 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
- Always provide SimpleForm/ListGuesser children in Create views
- Avoid conditionally undefined children expressions
- Add smoke tests that mount every resource view
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
- useReferenceFieldController: missing reference prop. You mus
- useShowController requires an id prop or a route with an /:i
- useNextPrevController was called outside of a ResourceContex
- To create a new option, you must pass an onCreate function o
- <InfiniteListBase> requires either a 'render' prop or 'child
AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30).
Data as JSON: /api/errors/5bc6faaec8ab655c.
Report an issue: GitHub.