Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

"Error: Element type is invalid" when using ReferenceInput inside CreateGusser

Open
#591 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start by reproducing the reported CreateGuesser case with an InputGuesser and then a ReferenceInput from react-admin, using the example in the issue. Trace how CreateGuesser renders its children and identify why ReferenceInput is treated as an invalid element. Done means the reference input renders without the reported error and the existing create fields continue to work.

Written by the indexing model from the issue text.

Description

API Platform version(s) affected: 4.0.3

Description
I have a resource named categories which has a CreateCategory component to define its create fields like this:

import {
  CreateGuesser,
  InputGuesser,
} from '@api-platform/admin';

const CreateCategory = (props: any) => (
  <CreateGuesser {...props}>
    <InputGuesser source="title" />
    <InputGuesser source="parent" />
  </CreateGuesser>
);

export default CreateCategory;

It's working properly but when I want to customize parent field by using ReferenceField like this:

import {
  CreateGuesser,
  InputGuesser,
} from '@api-platform/admin';
import { ReferenceInput } from "react-admin";

const CreateCategory = (props: any) => (
  <CreateGuesser {...props}>
    <InputGuesser source="title" />
    <ReferenceInput source="parent" reference="categories" />
  </CreateGuesser>
);

export default CreateCategory;

I am getting error:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `Error3`.
    at createFiberFromTypeAndProps (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:20471:25)
    at createFiberFromElement (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:20492:23)
    at reconcileSingleElement (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:10531:31)
    at reconcileChildFibers2 (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:10568:43)
    at reconcileChildren (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:14310:37)
    at updateHostComponent (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:14827:11)
    at beginWork (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:15955:22)
    at beginWork$1 (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:19781:22)
    at performUnitOfWork (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:19226:20)
    at workLoopSync (http://localhost:5173/node_modules/.vite/deps/chunk-ICOORQWA.js?v=5322f6b5:19165:13)

How to reproduce
The way of reproducing is already explained in the description.

Dominant language
TypeScript
Stars
516
Forks
134
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from api-platform/admin

All issues in api-platform/admin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.