Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsx中使用DatePicker,报错:“DatePicker”不能用作 JSX 组件。 #35771

Closed
btnkr opened this issue May 27, 2022 · 4 comments
Closed
Labels
🤔 Need Reproduce We cannot reproduce your problem

Comments

@btnkr
Copy link

btnkr commented May 27, 2022

Reproduction link

Edit on CodeSandbox

Steps to reproduce

ts中引入DatePicker,使用DatePicker

node 16.15.0

ts 4.7.2

@types/react 18.0.9

@types/react-dom 18.0.5

What is expected?

不报错 正常使用

What is actually happening?

“DatePicker”不能用作 JSX 组件。
其实例类型 "Component<PickerProps & { status?: "" | "warning" | "error" | undefined; }, unknown, any> & CommonPickerMethods" 不是有效的 JSX 元素。
在这些类型中,"render()" 返回的类型不兼容。
不能将类型“React.ReactNode”分配给类型“import("/Users/******/node_modules/@types/hoist-non-react-statics/node_modules/@types/react/index").ReactNode”。
不能将类型“{}”分配给类型“ReactNode”。ts(2786)

image

image

Environment Info
antd 4.20.6
React 17.0.2
System macOS Monterey12.3.1
Browser chrome 100.0.4896.127
@zombieJ
Copy link
Member

zombieJ commented May 27, 2022

你的重现看起来没有问题?

@zombieJ zombieJ added the 🤔 Need Reproduce We cannot reproduce your problem label May 27, 2022
@github-actions
Copy link
Contributor

Hello @btnkr. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 3 days.

你好 @btnkr, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。

@btnkr
Copy link
Author

btnkr commented May 29, 2022

你的重现看起来没有问题?

我在package.json加上了

    "resolutions": {
        "@types/react": "17.0.45"
    }

这个问题就没了

之前@types/react版本是18.0.9

@afc163
Copy link
Member

afc163 commented May 30, 2022

我 reopen 了 #34952,在这里跟踪

@afc163 afc163 closed this as completed May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 Need Reproduce We cannot reproduce your problem
Projects
None yet
Development

No branches or pull requests

3 participants