-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example #16449
Comments
A complete reproduction repository is required to investigate. |
@timneutkens https://github.com/blerp/website here you go! |
Any hints would be much appreciated!! @timneutkens |
I marked it as good first issue. |
Following. We're having a similar issue. |
I'm facing a similar issue, but only in SSG pages. |
I confirm this issue. Also I noticed the following messages in browser console: |
I got same error.. I use class components only in _app.tsx and _document.tsx |
I have a few select components in my application that will not only not hot reload but won't reload on a full refresh either. I need to run a completely new build to see reflected changes .. any quick thought on why this might be? The only thing that jumps out is that I'm doing a dynamic import in the parent component with |
Okay.. so for me it was a very silly issue - I had a component nested in a folder |
I might be experiencing the same issue... but I did not fully understand the explanation. I understood it is an issue with casing, but where? i.e. what casing needs to match which one? |
@JoseFMP for me it was the casing of a folder that I was referencing within my app. There was a folder with all lowercase, and I was referencing it in a file as capitalized. The app still built (and deployed) but Fast Refresh wouldn't work (or any refresh). As soon as I fixed the casing, Fast Refresh returned. For this example, the only (perhaps unhelpful) help I can offer is to scrupulously check all your file imports and make sure they match. Understand that my comment does not wholly reflect the open issue, just what I experienced. |
i have similar issue, i lost cache data after the |
This comment has been minimized.
This comment has been minimized.
I was/am having this issue and have been for the last 2 weeks or so. |
@garretteklof you saved me so much pain, thank you 💯 This was indeed the reason why my changes weren't being recompiled and refreshed in the browser. I had a folder with a capital letter as the first letter, but then I imported it in lower case. The super confusing thing was that I could restart the server manually and I would then see my changes, but that would never have led me to understand that the root of the problem was a casing issue. |
I had the same issue with nextjs v10.0.5. Application reflecting changes only in _document file and after that routes it stops reflecting at all other routes. triangle indicator showing after fast refresh in the console but changes not reflecting at all I was a need to manually refresh the browser in order to see changes. |
I'm having same issue. Tried your solution but the problem persist. (before: react 16.8.0, now: 17.0.1) |
Same issue, but neither solution helped in my case. For me my main index page hot reloads correctly, but all other pages has the same affect as reported here. Console says it's doing a "Fast refresh" but nothing updates. Any updates/solution on this? |
I notice when I use Ubuntu LTS 20.04 I do not experience this issue but if I just try to run |
I solved it, in my case. |
Encountered a similar or same bug in [email protected]. On a rebuild that appeared to trigger a refresh, but where my changes were not reflected, I noticed I got a "build" event over the Opting out of webpack 5 with the following module.exports = {
future: {
webpack5: false,
},
} @MarkLyck you might try the above and see if it does anything for you as we had close next and react versions. |
Happened to me too. I was just starting with Next.js, using this tutorial: Created the three components in the example, tried to change the backgroundColor, and it stopped responding to changes. Even after refresh, the color was outdated. I notice it always responds to one change after a server restart, and then breaks. |
I am having the same issue across multiple computers, disabling webpack 5 doesn't seem to have fixed it. |
FWIW I was not able to repro the issue on a fresh project. Original project it happened on is private unfortunately. Only difference that seems like it might be substantive was |
I seem to have fixed it, make sure the casing in all of your imports is correct, I had an incorrect capital letter, changing it seems to have fixed hot reloading not working. |
In my case the issue was due to using HOC(high order component) which is already mentioned by nextjs documentation |
I am using this: "scripts": {
"dev": "next dev -H ::",
//etc...
}, Works for me. |
this helped me |
I was using Ubuntu WSL in my Windows. Shifting back to Powershell worked for me. So maybe if you are using WSL or Docker or something like that,maybe shift back to Windows or your local system. |
It is because fast reload couldn't treat the imported component as react component. importing react in the imported element (import React from 'react') will resolve the issue. |
What does the flag -H mean? |
You can run
|
Edit: Turns out it wasn't relevant to this issue, I somehow never learned I should declare components using |
Here my 2cents, I was having hot reload problems ONLY in a component and got it resolved changing the first capital letter of my component .js file to a lowercase one.
package.json
|
This was the hint to lead me to my solution. I was building a Checkout Wizard, that loads the sub pages dynamically from an array of objects, e.g. // [[...step]].jsx
const steps = [
{ component: Step1, title: "Details" },
{ component: Step2, title: "Confirm" },
{ component: Step3, title: "Pay" },
];
function Checkout(){
const renderCurrentStep = steps[0].component // ... would do logic for dynamic render here
return (
<Layout>
{renderCurrentStep && renderCurrentStep}
</Layout>
);
} This did render my component, and would also have Hot Reload'ed in a React project. It's a valid approach. But somehow, not working in Next.js & fast reload.. The solution was to load them in as a Component, and not as a component variable. // [[...step]].jsx
const steps = [
{ component: <Step1/>, title: "Details" },
{ component: <Step2/>, title: "Confirm" },
{ component: <Step3/>, title: "Pay" },
];
function Checkout(){
const renderCurrentStep = steps[0].component // ... would do logic for dynamic render here
return (
<Layout>
{renderCurrentStep && renderCurrentStep}
</Layout>
);
} |
In my case the problem was no auto save in my code editor. I recently installed vs code and forgot to set this setting. Good luck |
In my case I had the option |
if you are on windows make sure to install npm on PowerShell, not on WSL |
The docker-compose file manages the containers and provides the needed environment for development. References: Building and deploying Next.js applications with Docker - YouTube https://www.youtube.com/watch?v=aNh8iShFXto Koyeb - How to Dockerize and Deploy a Next.js Application on Koyeb https://www.koyeb.com/tutorials/how-to-dockerize-and-deploy-a-next-js-application-on-koyeb How To Connect Docker With Python Flask And ReactJS FrontEnd | Docker Flask React Made Easy| 2021 HD - YouTube https://www.youtube.com/watch?v=ISCiJmY1g2M react-flask-postgres-boilerplate-with-docker/docker-compose.yml at master · tomahim/react-flask-postgres-boilerplate-with-docker https://github.com/tomahim/react-flask-postgres-boilerplate-with-docker/blob/master/docker-compose.yml Implement Docker With Hot Reloading In Next JS | by Bikash dulal | wesionaryTEAM | Medium https://medium.com/wesionary-team/impledocker-with-hot-reloading-in-next-js-f3e57fba84ce Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example · Issue #16449 · vercel/next.js vercel/next.js#16449 NextJS Fast Refresh - GeeksforGeeks https://www.geeksforgeeks.org/nextjs-fast-refresh/
References: Implement Docker With Hot Reloading In Next JS | by Bikash dulal | wesionaryTEAM | Medium https://medium.com/wesionary-team/impledocker-with-hot-reloading-in-next-js-f3e57fba84ce Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker nextjs-docker/next.config.js at main · Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker/blob/main/next.config.js Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example · Issue #16449 · vercel/next.js vercel/next.js#16449 NextJS Fast Refresh - GeeksforGeeks https://www.geeksforgeeks.org/nextjs-fast-refresh/ next.config.js: Custom Webpack Config | Next.js https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config Hot reloading Next.js with Docker in development | James Chambers https://jameschambers.co.uk/nextjs-hot-reload-docker-development https://jameschambers.co.uk/nextjs-hot-reload-docker-development#step-3-update-nextconfigjs Building and deploying Next.js applications with Docker - YouTube https://www.youtube.com/watch?v=aNh8iShFXto Koyeb - How to Dockerize and Deploy a Next.js Application on Koyeb https://www.koyeb.com/tutorials/how-to-dockerize-and-deploy-a-next-js-application-on-koyeb How To Connect Docker With Python Flask And ReactJS FrontEnd | Docker Flask React Made Easy| 2021 HD - YouTube https://www.youtube.com/watch?v=ISCiJmY1g2M react-flask-postgres-boilerplate-with-docker/docker-compose.yml at master · tomahim/react-flask-postgres-boilerplate-with-docker https://github.com/tomahim/react-flask-postgres-boilerplate-with-docker/blob/master/docker-compose.yml
The docker-compose file manages the containers and provides the needed environment for development. References: Building and deploying Next.js applications with Docker - YouTube https://www.youtube.com/watch?v=aNh8iShFXto Koyeb - How to Dockerize and Deploy a Next.js Application on Koyeb https://www.koyeb.com/tutorials/how-to-dockerize-and-deploy-a-next-js-application-on-koyeb How To Connect Docker With Python Flask And ReactJS FrontEnd | Docker Flask React Made Easy| 2021 HD - YouTube https://www.youtube.com/watch?v=ISCiJmY1g2M react-flask-postgres-boilerplate-with-docker/docker-compose.yml at master · tomahim/react-flask-postgres-boilerplate-with-docker https://github.com/tomahim/react-flask-postgres-boilerplate-with-docker/blob/master/docker-compose.yml Implement Docker With Hot Reloading In Next JS | by Bikash dulal | wesionaryTEAM | Medium https://medium.com/wesionary-team/impledocker-with-hot-reloading-in-next-js-f3e57fba84ce Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example · Issue #16449 · vercel/next.js vercel/next.js#16449 NextJS Fast Refresh - GeeksforGeeks https://www.geeksforgeeks.org/nextjs-fast-refresh/
References: Implement Docker With Hot Reloading In Next JS | by Bikash dulal | wesionaryTEAM | Medium https://medium.com/wesionary-team/impledocker-with-hot-reloading-in-next-js-f3e57fba84ce Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker nextjs-docker/next.config.js at main · Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker/blob/main/next.config.js Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example · Issue #16449 · vercel/next.js vercel/next.js#16449 NextJS Fast Refresh - GeeksforGeeks https://www.geeksforgeeks.org/nextjs-fast-refresh/ next.config.js: Custom Webpack Config | Next.js https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config Hot reloading Next.js with Docker in development | James Chambers https://jameschambers.co.uk/nextjs-hot-reload-docker-development https://jameschambers.co.uk/nextjs-hot-reload-docker-development#step-3-update-nextconfigjs Building and deploying Next.js applications with Docker - YouTube https://www.youtube.com/watch?v=aNh8iShFXto Koyeb - How to Dockerize and Deploy a Next.js Application on Koyeb https://www.koyeb.com/tutorials/how-to-dockerize-and-deploy-a-next-js-application-on-koyeb How To Connect Docker With Python Flask And ReactJS FrontEnd | Docker Flask React Made Easy| 2021 HD - YouTube https://www.youtube.com/watch?v=ISCiJmY1g2M react-flask-postgres-boilerplate-with-docker/docker-compose.yml at master · tomahim/react-flask-postgres-boilerplate-with-docker https://github.com/tomahim/react-flask-postgres-boilerplate-with-docker/blob/master/docker-compose.yml
The docker-compose file manages the containers and provides the needed environment for development. References: Building and deploying Next.js applications with Docker - YouTube https://www.youtube.com/watch?v=aNh8iShFXto Koyeb - How to Dockerize and Deploy a Next.js Application on Koyeb https://www.koyeb.com/tutorials/how-to-dockerize-and-deploy-a-next-js-application-on-koyeb How To Connect Docker With Python Flask And ReactJS FrontEnd | Docker Flask React Made Easy| 2021 HD - YouTube https://www.youtube.com/watch?v=ISCiJmY1g2M react-flask-postgres-boilerplate-with-docker/docker-compose.yml at master · tomahim/react-flask-postgres-boilerplate-with-docker https://github.com/tomahim/react-flask-postgres-boilerplate-with-docker/blob/master/docker-compose.yml Implement Docker With Hot Reloading In Next JS | by Bikash dulal | wesionaryTEAM | Medium https://medium.com/wesionary-team/impledocker-with-hot-reloading-in-next-js-f3e57fba84ce Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example · Issue #16449 · vercel/next.js vercel/next.js#16449 NextJS Fast Refresh - GeeksforGeeks https://www.geeksforgeeks.org/nextjs-fast-refresh/
References: Implement Docker With Hot Reloading In Next JS | by Bikash dulal | wesionaryTEAM | Medium https://medium.com/wesionary-team/impledocker-with-hot-reloading-in-next-js-f3e57fba84ce Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker nextjs-docker/next.config.js at main · Bikash888/nextjs-docker https://github.com/Bikash888/nextjs-docker/blob/main/next.config.js Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example · Issue #16449 · vercel/next.js vercel/next.js#16449 NextJS Fast Refresh - GeeksforGeeks https://www.geeksforgeeks.org/nextjs-fast-refresh/ next.config.js: Custom Webpack Config | Next.js https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config Hot reloading Next.js with Docker in development | James Chambers https://jameschambers.co.uk/nextjs-hot-reload-docker-development https://jameschambers.co.uk/nextjs-hot-reload-docker-development#step-3-update-nextconfigjs Building and deploying Next.js applications with Docker - YouTube https://www.youtube.com/watch?v=aNh8iShFXto Koyeb - How to Dockerize and Deploy a Next.js Application on Koyeb https://www.koyeb.com/tutorials/how-to-dockerize-and-deploy-a-next-js-application-on-koyeb How To Connect Docker With Python Flask And ReactJS FrontEnd | Docker Flask React Made Easy| 2021 HD - YouTube https://www.youtube.com/watch?v=ISCiJmY1g2M react-flask-postgres-boilerplate-with-docker/docker-compose.yml at master · tomahim/react-flask-postgres-boilerplate-with-docker https://github.com/tomahim/react-flask-postgres-boilerplate-with-docker/blob/master/docker-compose.yml
This also broke for me after upgrading to next |
Confirmed this broke after updating from |
I swear it took me hours of combing through my code and it turns out it was this silly issue as well 😅 |
Yep, this was exactly my issue! Edits to my component wouldn't reload. I couldn't figure out why, but it turns out I was calling it from the parent as a function ( |
Disabling webpack5 in next.config solved my issue. {
//...
webpack5: false
} |
Damnnnnnnn!!!! It Worked |
Bug report
We are running
"dev": "cross-env NODE_ENV=development babel-node src/server.js",
to start nextjs in dev mode from our server.js fileWe see the compiled successfully message when making changes to the pages/components folder
but we do not see any changes or renders on the page until we refresh the page
Describe the bug
Next.js, not rerendering page when changes are made to the app.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
Hot reloading should rerender the page
System information
Code Example
_app.js
_documents.js
The text was updated successfully, but these errors were encountered: