question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'Error: Invalid hook call. Hooks can only be called inside of the body of a function component'

See original GitHub issue

Bug 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

  1. Start a new next app with npx create-next-app moshood.dev
  2. Start the next development server with yarn dev
  3. Navigate to localhost:3000 in the browser after starting development server
  4. 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

next error scrnli_10_3_2020_6-29-40 PM

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:closed
  • Created 3 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
mohesemcommented, Oct 5, 2020

same error here

2reactions
nickpassarellacommented, Oct 19, 2020

It looks like my issue is unrelated to @olalekanteeblaze’s. I had a mistake in my next.config.js that I think was writing over next webpack externals. Perhaps this was affecting react versions under the hood?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found