🧐[问题] ProFormUploadButton cannot be used as a JSX component
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
🧐 问题描述
"@ant-design/pro-components": "^2.8.8",
"antd": "^5.25.4",
"@ant-design/v5-patch-for-react-19": "^1.0.3",
在同步 antd-pro 的 master 分支后提示 ProFormUploadButton cannot be used as a JSX component
import { ProFormUploadButton, } from '@ant-design/pro-components';
💻 示例代码
🚑 其他信息
以下的 Issues 可能会帮助到你 / The following issues may help you
- [#9080][🐛[BUG] ProFormUploadButton报错cannot be used as a JSX component.][77%]
ProFormUploadButton 在源码中是一个标准的 React 组件,导出和类型声明都没有问题,理论上可以直接作为 JSX 组件使用,并没有发现相关的已知 bug 或 breaking change[源码实现]。
出现 “cannot be used as a JSX component” 这种 TypeScript 报错,常见原因有:依赖包多版本冲突、ESM/CJS 混用、TypeScript 配置不兼容(比如 esModuleInterop/allowSyntheticDefaultImports)、或者 node_modules 缓存未清理。建议你:
- 检查 node_modules 和 lock 文件,确保没有多版本的 react/antd/pro-components,必要时删除 node_modules 和 lock 文件后重新安装依赖。
- 检查 tsconfig.json,确保 "esModuleInterop" 和 "allowSyntheticDefaultImports" 都为 true。
- 确认你的构建工具链(比如 webpack、vite)配置没有混用 ESM/CJS,且依赖都指向同一份 React。
- 如果还有问题,可以尝试在一个全新项目里只安装 antd/pro-components/react 这几个依赖,排查是否为环境或配置问题。
目前没有在官方 issue 或 PR 里发现和你描述的报错直接相关的内容[PR9040]。如果还有疑问,可以补充下你的 tsconfig 配置和依赖树,方便进一步定位。
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
+1
关闭这个 issues吧,升级 "@ant-design/pro-components": "3.0.2-0" @ToQuery