react-activation icon indicating copy to clipboard operation
react-activation copied to clipboard

ReactDOM.render(<AliveScope><App/></AliveScope>, document.getElementById('root')) throw ts error

Open Rainnut opened this issue 3 years ago • 5 comments

image

开发环境: "react": "^17.0.2", "react-activation": "^0.10.2", "react-dom": "^17.0.2", "react-error-boundary": "^3.1.4", "react-i18next": "^11.16.9", "react-router": "^5.2.1", "react-router-dom": "^5.2.0", "react-scripts": "5.0.1",

Rainnut avatar May 18 '22 12:05 Rainnut

外边裹一层 <></> 会好吗,不知道是不是 react 版本不一致的原因,AliveScore 的类型现在是 extends React.Component 的,讲道理不应该有这个问题

CJY0208 avatar May 28 '22 07:05 CJY0208

我也出现了这个错误,求解 'KeepAlive' cannot be used as a JSX component. Its instance type 'KeepAlive' 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(".../xxx-app/node_modules/@types/react-router/node_modules/@types/react/index").ReactNode'. Type '{}' is not assignable to type 'ReactNode'.ts(2786)

Daph01 avatar May 29 '22 15:05 Daph01

大概率是你装的第三方库里用的是@types/react 18的版本,18以后的react类型差别很大,可以通过yarn resolution降级,解决这个报错 "resolutions": { "@types/react": "17.0.45" },

wind4gis avatar Jun 20 '22 13:06 wind4gis

感谢,此方法有效! 帮我解决了困扰我许久的难题。虽然不知道是哪个库用了 @types/react 18

Daph01 avatar Jun 20 '22 14:06 Daph01

感谢,此方法有效! 帮我解决了困扰我许久的难题。虽然不知道是哪个库用了 @types/react 18

@Daph01 看看yarn.lock文件就可以排查

wind4gis avatar Jun 22 '22 07:06 wind4gis