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
'Error: Invalid hook call. Hooks can only be called inside of the body of a function component' #17592
Comments
These are the steps that set up a completely new Next.js application. Please provide a complete reproduction instead. |
same error here |
Maybe I didn't explain this well. This error is exactly what I get immediately I navigate to localhost:3000 after starting a new Next.js application. The reproduction process is just starting a new Next.js App. Might be peculiar to me though |
We experience the same issue as soon as we use the ^9.5 version. We had to downgrade to a 9.4(ish) version. it is strange because when developing locally, everything is working fine. |
@iliasbhal Are you symlinking your |
I'm getting this same issue on an existing project. I didn't make any major changes aside from an I did a little debugging, and it looks like something is setting I'm fairly new to Next, so I'm not sure if this is an issue with Next or React. Any chance this is related to facebook/react#14022? |
It looks like my issue is unrelated to @olalekanteeblaze's. I had a mistake in my |
Same problem since three days, after succesful build. Here the log: https://gist.github.com/StEvUgnIn/c74757a9efc9a3dbba6fb3c094f39bb0 |
This comment has been minimized.
This comment has been minimized.
This error was due to special characters ( |
#16369 fixed it for me. |
It's funny.. I get this error only when I run my nextjs project in https://github.com/Eugeny/terminus command line using powershell profile. However when I run my project in normal windows powershell, I don't get this error. |
This is what solved problem for me. In /** @type {import('next').NextConfig} */
module.exports = {
webpack: (config, options) => {
config.resolve.alias = {
...config.resolve.alias,
react: require.resolve('react').replace('index.js', ''),
};
return config;
},
}; Explanation: most likely Webpack/npm have issues correctly resolving React package, as the result there is more than one copy of React in the application. This will force webpack use the same copy of React everywhere. |
Hi, this appears to be a duplicate of #16535 so I'm gonna close this in favor of that one for tracking this. |
This fixes Next.js running into unexpected errors on Windows when invalid casing for a project directory is used. I was able to reproduce the issue on my local Windows machine and this resolved the issue there. <details> <summary>screenshot of error while reproducing</summary> <img width="838" alt="Screen Shot 2021-09-18 at 23 21 40" src="https://user-images.githubusercontent.com/22380829/133915825-ac4abdd2-fcf8-4309-9873-e6d88dfe485d.png"> </details> ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [x] Errors have helpful link attached, see `contributing.md` Fixes: #27396 Fixes: #16535 Fixes: #17592
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. |
) This fixes Next.js running into unexpected errors on Windows when invalid casing for a project directory is used. I was able to reproduce the issue on my local Windows machine and this resolved the issue there. <details> <summary>screenshot of error while reproducing</summary> <img width="838" alt="Screen Shot 2021-09-18 at 23 21 40" src="https://user-images.githubusercontent.com/22380829/133915825-ac4abdd2-fcf8-4309-9873-e6d88dfe485d.png"> </details> ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [x] Errors have helpful link attached, see `contributing.md` Fixes: vercel#27396 Fixes: vercel#16535 Fixes: vercel#17592
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
npx create-next-app moshood.dev
yarn dev
Expected behavior
Start default next app in the browser successfully.
Screenshots
System information
-Version of React-dom [16.13.1]
The text was updated successfully, but these errors were encountered: