【发布时间】:2022-08-02 20:02:36
【问题描述】:
我使用过 React 项目,与 Circle CI 集成,经过一些小的更改后,它开始使所有构建失败
Its instance type \'ReactApexChart\' is not a valid JSX element.
The types returned by \'render()\' are incompatible between these types.
Type \'React.ReactNode\' is not assignable to type \'import(\"/home/circleci/app.mxney-board-v2.test/node_modules/@types/react-transition-group/node_modules/@types/react/index\").ReactNode\'.
79 <Chart options={fillOptions} series={graphData} height={chartHeight} />
~~~~~
src/index.tsx:20:8 - error TS2786: \'App\' cannot be used as a JSX component.
Its element type \'ReactElement<any, any> | Component<Omit<Subtract<unknown, WithTranslationProps>, keyof WithTranslation<N>> & WithTranslationProps, any, any> | null\' is not a valid JSX element.
Type \'Component<Omit<Subtract<unknown, WithTranslationProps>, keyof WithTranslation<N>> & WithTranslationProps, any, any>\' is not assignable to type \'Element | ElementClass | null\'.
Type \'Component<Omit<Subtract<unknown, WithTranslationProps>, keyof WithTranslation<N>> & WithTranslationProps, any, any>\' is not assignable to type \'ElementClass\'.
The types returned by \'render()\' are incompatible between these types.
Type \'React.ReactNode\' is not assignable to type \'import(\"/home/circleci/app.mxney-board-v2.test/node_modules/@types/react-transition-group/node_modules/@types/react/index\").ReactNode\'.
20 <App />
~~~
在本地,项目运行没有问题。
我试过了:
- 更新@types 和库
- 删除 react-apexchart 库
- 移除 react-transition 库
- 删除 yarn.lock 一个 node_modules 并重新安装 - 这会破坏一切,我在本地收到此错误
-
我解决了这个问题 - 问题在于 HOC export const App = hot(withTranslation()(AppComponent)) 将其更改为 export const App = hot(withTranslation()(AppComponent as React.FC))
标签: reactjs typescript yarnpkg circleci