Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级后,如果使用的是老版本的写法,都会报hooks错误 #220

Open
nlx0201 opened this issue Mar 26, 2021 · 1 comment
Open

Comments

@nlx0201
Copy link

nlx0201 commented Mar 26, 2021

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
    at resolveDispatcher (VM119152 react.development.js:1476)
    at Object.useContext (VM119152 react.development.js:1484)
    at Button (button.js?cef1:129)
    at renderWithHooks (react-dom.js:15015)
    at updateForwardRef (react-dom.js:17074)
    at beginWork (react-dom.js:19128)
    at HTMLUnknownElement.callCallback (react-dom.js:3942)
    at Object.invokeGuardedCallbackDev (react-dom.js:3991)
    at invokeGuardedCallback (react-dom.js:4053)
    at beginWork$1 (react-dom.js:23994)

升级后在es6的写法中,如果是class里面render一个button都会报错,怎么处理?

antd版本4.14.1

@nlx0201
Copy link
Author

nlx0201 commented Mar 26, 2021

export default class Demo extends React.Component{
render(){
return 确定
}
}
如果此处的Button换成Input就没有问题,看了源码,应该是里面的useContext导致的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant