[英]cannot be used as a JSX component. Its return type 'void' is not a valid JSX element.ts(2786)
[英]'Component' cannot be used as a JSX component. Its element type 'ReactElement<any, any> | Component<{}, any, any>' is not a valid JSX element
这是完整的错误;
类型错误:“组件”不能用作 JSX 组件。 它的元素类型 'ReactElement<any, any> | Component<{}, any, any>' 不是有效的 JSX 元素。
<Loader />
) : (
getLayout(<Component {...pageProps} />)
^
)
}
</AuthConsumer>
错误命令失败,退出代码为 1。
我已经阅读了关于“组件不能用作 JSX 组件”的类似问题和帖子,但它们并没有帮助我继续前进。
版本:react、@types/react、@types/react-dom,均设置为版本 17.0.2
我已经删除了 package-lock.json 文件,现在只留下了 yarn-lock.json 文件
我缺少什么线索来解决这个难题?
亲切的问候
问题在于最新版本的 @types/react:18.xx 这可能是通过其他一些包的对等依赖项引入您的项目的。
如果您有 .tsconfig 文件,请将以下内容添加到 compilerOptions:
"paths": {
"react": [ "./node_modules/@types/react" ]
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.