react-activation
react-activation copied to clipboard
ReactDOM.render(<AliveScope><App/></AliveScope>, document.getElementById('root')) throw ts error
开发环境: "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",
外边裹一层 <></> 会好吗,不知道是不是 react 版本不一致的原因,AliveScore 的类型现在是 extends React.Component 的,讲道理不应该有这个问题
我也出现了这个错误,求解
'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)
大概率是你装的第三方库里用的是@types/react 18的版本,18以后的react类型差别很大,可以通过yarn resolution降级,解决这个报错
"resolutions": { "@types/react": "17.0.45" },
感谢,此方法有效! 帮我解决了困扰我许久的难题。虽然不知道是哪个库用了 @types/react 18
感谢,此方法有效! 帮我解决了困扰我许久的难题。虽然不知道是哪个库用了 @types/react 18
@Daph01 看看yarn.lock文件就可以排查