vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.37k stars 26.53k forks source link

Invalid hook call #9299

Closed Industrial closed 4 years ago

Industrial commented 4 years ago

Bug report

Describe the bug

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

To Reproduce

git clone https://github.com/Industrial/next-typescript-hooks-error.git
cd next-typescript-hooks-error
yarn dev

Expected behavior

My App Bar and Drawer (standard MaterialUI components) to render correctly.

Screenshots

The Error

Additional Info

This is where it breaks: https://github.com/Industrial/next-typescript-hooks-error/blob/master/src/app/components/Layout.tsx#L46

I'm not sure why the hook above it works which is a MaterialUI hook but one from React itself won't work ...

I guess it has to do with Server Side Rendering.

msreekm commented 4 years ago

i cloned your repo and ran yarn dev , i dont see that error. I tried navigating to both index and about routes.

Industrial commented 4 years ago

You are correct. How weird :S

balazsorban44 commented 2 years ago

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.