'Error: Invalid hook call. Hooks can only be called inside of the body of a function component'
See original GitHub issueBug report
Describe the bug
I keep ‘Error: Invalid hook call. Hooks can only be called inside of the body of a function component’ after starting the next development server. This is the default next app with no configuration from me at all
To Reproduce
- Start a new next app with
npx create-next-app moshood.dev
- Start the next development server with
yarn dev
- Navigate to localhost:3000 in the browser after starting development server
- Browser shows ‘internal server Error’ and terminal shows ‘Error: Invalid hook call. Hooks can only be called inside of the body of a function component’
Expected behavior
Start default next app in the browser successfully.
Screenshots
System information
- OS: [Windows]
- Browser [chrome]
- Version of Next.js: [9.5.3]
- Version of Node.js: [e.g. 12.18.2]
- Version of React [16.13.1] -Version of React-dom [16.13.1]
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (3 by maintainers)
Top Results From Across the Web
Invalid Hook Call Warning - React
Hooks can only be called inside the body of a function component. There are three common reasons you might be seeing it: You...
Read more >Invalid hook call. Hooks can only be called inside of the body ...
Invalid hook call. Hooks can only be called inside of the body of a function component · You might have mismatching versions of...
Read more >Invalid hook call. Hooks can only be called inside of the body ...
Like others have said: hooks can only be called in the body of a function component, you cannot call them conditionally or in...
Read more >Invalid hook call. Hooks can only be called inside of the body ...
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the...
Read more >Invalid hook call. Hooks can only be called inside the body of ...
Having a mismatch between the versions of react and react-dom . · Having multiple versions of the react package in the same project....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
same error here
It looks like my issue is unrelated to @olalekanteeblaze’s. I had a mistake in my
next.config.js
that I think was writing overnext
webpack externals. Perhaps this was affecting react versions under the hood?