react+umi项目中引入antd组件报错:“Button”不能用作 JSX 组件解决方案
具体报错信息
“Button”不能用作 JSX 组件。
Its type ‘(props: IProps) => React.ReactElement’ is not a valid JSX element type.
不能将类型“(props: IProps) => React.ReactElement”分配给类型“(props: any, deprecatedLegacyContext?: any) => ReactNode”。
不能将类型“ReactElement<any, string | JSXElementConstructor>”分配给类型“ReactNode”。
类型 “ReactElement<any, string | JSXElementConstructor>” 中缺少属性 “children”,但类型 “ReactPortal” 中需要该属性
解决方案
方式一.将tsconfig.json的配置
“compilerOptions” : {// "jsx": "react-jsx" 注释掉 改为"jsx": "react""jsx": "react"
}
方式二.安装 @types/react
npm install @types/react