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.

Invalid hook call

See original GitHub issue

If you use this component:

https://github.com/mui-org/material-ui/tree/master/docs/src/pages/getting-started/page-layout-examples/album

With this example project:

https://github.com/mui-org/material-ui/tree/master/examples/nextjs

You get:

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

How do we fix?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sorleonecommented, Jul 22, 2019

@oliviertassinari I don’t have another computer, but I can add that the problem shows up here:

./pages/_document.js:60

   7 | const sheets = new ServerStyleSheets();
  58 | const originalRenderPage = ctx.renderPage;
  59 | 
> 60 | ctx.renderPage = () =>
  61 |   originalRenderPage({
  62 |     enhanceApp: App => props => sheets.collect(<App {...props} />),
  63 |   });

and if you remove everything from the bottom up to and including this line, it goes away.

0reactions
cdllcommented, Oct 11, 2021

same issue with Stepper component

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Hook Call Warning - React
There are three common reasons you might be seeing it: You might have mismatching versions of React and React DOM. You might be...
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 ...
The error "Invalid hook call. Hooks can only be called inside the body of a function component" occurs for multiple reasons, having a...
Read more >
Invalid hook call - How to resolve multiple versions of React ...
I noticed that whenever I link each individually, the former unlinks. So by doing npm link ./path-to-app/node_modules/react ./path-to-app/ ...
Read more >
Invalid hook call. Hooks can only be called ... - Datainfinities
React error “Invalid hook call. Hooks can only be called inside the body of a function component” occurs due to many reasons. Learn...
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