Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#591 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react, typescript
领域
frontend

调研方向

首先,使用 issue 中的示例,通过一个 InputGuesser 以及随后一个来自 react-admin 的 ReferenceInput,重现报告的 CreateGuesser 案例。跟踪 CreateGuesser 如何渲染其子元素,并确定 ReferenceInput 被视为无效元素的原因。当引用输入能够在不出现所报告错误的情况下渲染,并且现有的创建字段继续正常工作时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
516
派生
134
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

api-platform/admin 的其他 Issue

查看 api-platform/admin 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。