-
Notifications
You must be signed in to change notification settings - Fork 46.7k
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
Hook Error: Hooks can only be called inside the body of a function component #14823
Comments
Did you follow the link in the error message and read that page listing the common causes for it? Which ones have you verified? |
You might have mismatching versions of React and React DOM. Verified: Both on 16.8.1 You might be breaking the Rules of Hooks. Verified. You might have more than one copy of React in the same app. How can I verify this? |
The code works in a sandbox environment: https://codesandbox.io/s/5zj5o023vp (thanks @ryancogswell) It seems as though the devDependencies in
Line 134: https://github.com/apollographql/react-apollo/blob/master/package.json Tracking issue: apollographql/react-apollo#2792 |
That's likely the issue. Closing this one in favour of the one on react-apollo, cheers. |
The page answers that too. https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When using
useState()
hook in a functional component, I get the following error:If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
The functional component where the hook is being used:
package.json:
What is the expected behavior?
App should run without any errors.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React: 16.8.1
ReactDOM: 16.8.1
Chrome: 71.0.3578.98
The text was updated successfully, but these errors were encountered: