[英]'Component' cannot be used as a JSX component. Its element type 'ReactElement<any, any> | Component<{}, any, any>' is not a valid JSX element
Here is the full error;这是完整的错误;
Type error: 'Component' cannot be used as a JSX component.类型错误:“组件”不能用作 JSX 组件。 Its element type 'ReactElement<any, any> |
它的元素类型 'ReactElement<any, any> | Component<{}, any, any>' is not a valid JSX element.
Component<{}, any, any>' 不是有效的 JSX 元素。
<Loader />
) : (
getLayout(<Component {...pageProps} />)
^
)
}
</AuthConsumer>
error Command failed with exit code 1.错误命令失败,退出代码为 1。
I have read similar questions and posts about this "component cannot be used as a JSX component" and they have not helped me on my quest to move forward.我已经阅读了关于“组件不能用作 JSX 组件”的类似问题和帖子,但它们并没有帮助我继续前进。
Versions: react, @types/react, @types/react-dom, all set to version 17.0.2版本:react、@types/react、@types/react-dom,均设置为版本 17.0.2
I have deleted the package-lock.json files and left only the yarn-lock.json files for now我已经删除了 package-lock.json 文件,现在只留下了 yarn-lock.json 文件
What clue am I missing to solve this puzzle?我缺少什么线索来解决这个难题?
kind regards亲切的问候
The Issue is with Latest Version of @types/react:18.xx This may have been introduced to your project via some other packages' peer dependency.问题在于最新版本的 @types/react:18.xx 这可能是通过其他一些包的对等依赖项引入您的项目的。
If you have a .tsconfig file, Add following to compilerOptions:如果您有 .tsconfig 文件,请将以下内容添加到 compilerOptions:
"paths": {
"react": [ "./node_modules/@types/react" ]
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.