Skip to content
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

Open
aaronkchsu opened this issue Aug 21, 2020 · 47 comments
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@aaronkchsu
Copy link

aaronkchsu commented Aug 21, 2020

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 file

We see the compiled successfully message when making changes to the pages/components folder
image

but we do not see any changes or renders on the page until we refresh the page

import express from "express";
import "isomorphic-fetch";
import next from "next";
import projectConfig from "./config";

import { initializeApollo } from "./lib/nextApollo";
import gql from "graphql-tag";

const compression = require("compression");
const apiHost = projectConfig.apiHost;
const currentHost = projectConfig.host;
const env = projectConfig.env;

// export interface Global extends NodeJS.Global {
//   document: Document;
//   window: Window;
//   DEVELOPMENT: any;
//   FOLDER: any;
// }

// declare var global: Global;

global.DEVELOPMENT = projectConfig.env == "DEV" ? true : false;
const dev = global.DEVELOPMENT ? true : false;
const folder = global.DEVELOPMENT ? "src" : "dist";

console.log("IS DEVELOPMENT", dev, "FOLDER", folder);

const app = next({ dev, dir: folder });

const handle = app.getRequestHandler();
const server = express();

server.use(compression());

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:

  1. Run app
  2. Go to page in a browser
  3. Make a change on page
  4. See compiled successfully but no rerender

Expected behavior

Hot reloading should rerender the page

System information

  • OS: Mac and windows
  • Browser all Browsers
  • Version of Next.js: 9.3 and 9.5
  • Version of Node.js: 12

Code Example

export const resolvers = {
    Mutation: {
        setGlobalVolume: (_, { volume }, { cache }) => {
            // cache.writeData({ data: { globalVolume: volume } });
            return null;
        },
        setGlobalSrc: (_, { id }, { cache }) => {
            // cache.writeData({ data: { globalSrcId: id } });
            return null;
        },
    },
};

const authLink = setContext((_, { headers }) => {
    if (projectConfig.env === "DEV") {
        // get the authentication token from local storage if it exists
        const token = isBrowser
            ? window.localStorage
                ? window.localStorage.getItem("jwt")
                : ""
            : "";

        // return the headers to the context so httpLink can read them
        return {
            headers: {
                ...headers,
                authorization: token ? `Bearer ${token}` : "",
            },
        };
    } else {
        return {
            headers: {
                ...headers,
            },
        };
    }
});

// https://www.apollographql.com/docs/react/caching/cache-configuration/
const apolloCache = new InMemoryCache({
    dataIdFromObject(responseObject) {
        switch (responseObject.__typename) {
            case "Bite":
                return `Bite:${responseObject._id}`;
            case "Playlist":
                return `Playlist:${responseObject._id}`;
            case "Category":
                return `Category:${responseObject._id}`;
            case "User":
                return `User:${responseObject._id}`;
            default:
                return defaultDataIdFromObject(responseObject);
        }
    },
    typePolicies: {
        Bite: {
            fields: {
                audio: {
                    original: {
                        merge(existing, incoming, { mergeObjects }) {
                            return existing._id;
                        },
                    },
                },
            },
        },
        Query: {
            queryType: true,
            fields: {
                web: {
                    merge: true,
                    queryType: true,
                },
                twitch: {
                    merge: true,
                    queryType: true,
                },
            },
        },
    },
});

export function initializeApollo(initialState = {}) {
    const _apolloClient = apolloClient || createApolloClient();

    // If your page has Next.js data fetching methods that use Apollo Client, the initial state
    // gets hydrated here
    if (initialState) {
        // Get existing cache, loaded during client side data fetching
        const existingCache = _apolloClient.extract();
        // Restore the cache using the data passed from getStaticProps/getServerSideProps
        // combined with the existing cached data
        _apolloClient.cache.restore({ ...existingCache, ...initialState });
    }
    // For SSG and SSR always create a new Apollo Client
    if (typeof window === "undefined") return _apolloClient;
    // Create the Apollo Client once in the client
    if (!apolloClient) apolloClient = _apolloClient;

    return _apolloClient;
}

export function useApollo(initialState) {
    const store = useMemo(() => initializeApollo(initialState), [initialState]);
    return store;
}

_app.js

import React from "react";
import { ApolloProvider } from "@apollo/client";
import { useApollo } from "../lib/nextApollo";
import * as ReactGA from "react-ga";

import { Helmet } from "react-helmet";

import { Themes } from "@blerp/design";
import { colors } from "../components/theme/Theme";
import { ThemeProvider } from "styled-components";

// https://github.com/vercel/next.js/tree/canary/examples/with-apollo For apollo + nextjs example
export default function App({ Component, pageProps }) {
    const apolloClient = useApollo(pageProps.initialApolloState);

    return (
        <ApolloProvider client={apolloClient}>
            <ThemeProvider
                theme={{
                    ...Themes.mainTheme,
                    colors: colors,
                    mode: "light",
                }}
            >
                <>
                    <Helmet defaultTitle='Blerp' titleTemplate='%s' />
                    <Component {...pageProps} />
                </>
            </ThemeProvider>
        </ApolloProvider>
    );
}

_documents.js

    static async getInitialProps(ctx) {
        const sheet = new ServerStyleSheet();
        const originalRenderPage = ctx.renderPage;
        try {
            ctx.renderPage = () =>
                originalRenderPage({
                    enhanceApp: App => props =>
                        sheet.collectStyles(<App {...props} />),
                });

            const initialProps = await Document.getInitialProps(ctx);
            return {
                ...initialProps,
                styles: (
                    <>
                        {initialProps.styles}
                        {sheet.getStyleElement()}
                    </>
                ),
            };
        } finally {
            sheet.seal();
        }
    }

@aaronkchsu aaronkchsu changed the title Hot Reloading Next.js 9 using custom routing, styled components and withApollo example Hot Reloading not Working Next.js 9 using custom routing, styled components and withApollo example Aug 21, 2020
@aaronkchsu aaronkchsu changed the title Hot Reloading not Working Next.js 9 using custom routing, styled components and withApollo example Hot Reloading not Rerendering pages in Next.js 9 using custom routing, styled components and withApollo example Aug 21, 2020
@aaronkchsu aaronkchsu changed the title Hot Reloading not Rerendering pages in Next.js 9 using custom routing, styled components and withApollo example Hot Reloading not working in Next.js 9 using custom routing, styled components and withApollo example Aug 21, 2020
@timneutkens timneutkens added the please add a complete reproduction Please add a complete reproduction. label Aug 22, 2020
@timneutkens
Copy link
Member

A complete reproduction repository is required to investigate.

@aaronkchsu
Copy link
Author

@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers and removed please add a complete reproduction Please add a complete reproduction. labels Aug 22, 2020
@timneutkens timneutkens added this to the backlog milestone Aug 22, 2020
@aaronkchsu
Copy link
Author

Any hints would be much appreciated!! @timneutkens

@timneutkens
Copy link
Member

I marked it as good first issue.

@ydax
Copy link

ydax commented Aug 25, 2020

Following. We're having a similar issue.

@vibhanshu909
Copy link

I'm facing a similar issue, but only in SSG pages.

@alexey-kuznetsov
Copy link

I confirm this issue. Also I noticed the following messages in browser console:
[Fast Refresh] rebuilding [Fast Refresh] done
And triangular indicator of updating at right bottom corner of screen appears and disappears, but nothing happened - changes do not apply.

@Suniron
Copy link

Suniron commented Sep 27, 2020

I got same error.. I use class components only in _app.tsx and _document.tsx

@garretteklof
Copy link

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 ssr: false however commenting this component out does nothing. I'm also getting no 'Fast Refresh' indication in the console.

@garretteklof
Copy link

Okay.. so for me it was a very silly issue - I had a component nested in a folder controls but I was referencing it from another component as from ./Controls. The casing was the issue - however, everything was rendering / displaying as normal (just no fast refresh), and there were no warnings in the console. I received a warning only after I took a child component in controls and rendered it directly from the component further up the tree. I understand these are separate issues, but just in case someone stumbles across this: casing matters for Fast Refresh (but not always for the build), and if it's nested - it may swallow the warning.

@JoseFMP
Copy link

JoseFMP commented Oct 17, 2020

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?

@garretteklof
Copy link

@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.

@raymclee
Copy link

raymclee commented Nov 9, 2020

i have similar issue, i lost cache data after the [Fast Refresh] done

@Timer Timer removed this from the backlog milestone Nov 11, 2020
@DiogoMaMartins

This comment has been minimized.

@hutber
Copy link

hutber commented Jan 11, 2021

I was/am having this issue and have been for the last 2 weeks or so.
So if you want to force case checking on file imports, its worth using:
eslint import/no-unresolved
This rule is case sensitive by default. I had disabled this around 2 weeks ago!! Dog!!

@hichana
Copy link

hichana commented Jan 12, 2021

@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.

@Bekhzod96
Copy link

Bekhzod96 commented Jan 20, 2021

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.
SOLUTION IN MY CASE
I find out this problem was related to my react version I deleted react and react-dom from paskage.json and reinstalled it again with a newer version.

@pmdpaula
Copy link

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.
SOLUTION IN MY CASE
I find out this problem was related to my react version I deleted react and react-dom from paskage.json and reinstalled it again with a newer version.

I'm having same issue. Tried your solution but the problem persist. (before: react 16.8.0, now: 17.0.1)

@MarkLyck
Copy link

MarkLyck commented Mar 4, 2021

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?

[email protected]
[email protected]

@oseisaac
Copy link

oseisaac commented May 5, 2021

I notice when I use Ubuntu LTS 20.04 I do not experience this issue but if I just try to run npx create-next-app on my local evn it doesn't show updates

@la-idea
Copy link

la-idea commented May 17, 2021

I solved it, in my case.
When I run with "yarn start" or "npm run start", it is used in the production environment and does not reload build changes. We have to use "yarn run dev" or "npm run dev".

@Lanny
Copy link

Lanny commented Jun 14, 2021

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 webpack-hmr WS connection but the hash key was the same after making changes and saving, so presumably the client refused to refresh on the grounds that (bundle?) hash had not changed.

Opting out of webpack 5 with the following next.config.js file seems to have fixed it:

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.

@siolfyr
Copy link

siolfyr commented Jul 2, 2021

Happened to me too. I was just starting with Next.js, using this tutorial:
https://auth0.com/blog/next-js-practical-introduction-for-react-developers-part-1/

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.

@Thomas13702
Copy link

I am having the same issue across multiple computers, disabling webpack 5 doesn't seem to have fixed it.

@Lanny
Copy link

Lanny commented Jul 10, 2021

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 paths in the typescript config.

@Thomas13702
Copy link

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.

@SarkarKurdish
Copy link

In my case the issue was due to using HOC(high order component) which is already mentioned by nextjs documentation

Link to the subject

@KoBa4
Copy link

KoBa4 commented Aug 3, 2021

I am using this: -H ::

"scripts": {
  "dev": "next dev -H ::",
   //etc...
},

Works for me.

@richinrix
Copy link

I was/am having this issue and have been for the last 2 weeks or so.
So if you want to force case checking on file imports, its worth using:
eslint import/no-unresolved
This rule is case sensitive by default. I had disabled this around 2 weeks ago!! Dog!!

this helped me
instead of importing the regular way do
const { default: About } = require("../components/About");

@harshitaTurtleTechSai
Copy link

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.

@sajibarafatsiddiqui
Copy link

sajibarafatsiddiqui commented Mar 5, 2022

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.

@nyambura00
Copy link

I am using this: -H ::

"scripts": {
  "dev": "next dev -H ::",
   //etc...
},

Works for me.

What does the flag -H mean?

@balazsorban44
Copy link
Member

You can run next dev --help

--hostname, -H Hostname on which to start the application (default: 0.0.0.0)

@yan3321
Copy link

yan3321 commented Mar 10, 2022

Having a similar issue. The "reload triangle" shows in the bottom corner and fast refresh is logged in console, but changes made to all imported components do not reflect accordingly.

Double-checked the casing of import paths and issue still persists. Non-imported components in the same file are not affected and update as intended.

[email protected], [email protected]

Edit: Turns out it wasn't relevant to this issue, I somehow never learned I should declare components using <Component/> instead of { Component() }. Rookie mistake, but hope it helps someone coming across the same problem.

@JulioSimon
Copy link

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.

Having the first capital letter at the filename was causing the hot reload problem.

...
/components
|____ComponentFile.js
...
export default function ComponentFile(){
   ...
}

After changing the capital letter to a lower case one, the hot reload function on the component started to work again.

...
/components
|____componentFile.js
...
export default function ComponentFile(){
   ...
}

package.json

"next": "12.1.1",
"react": "17.0.2",

@advename
Copy link

Edit: Turns out it wasn't relevant to this issue, I somehow never learned I should declare components using <Component/> instead of { Component() }. Rookie mistake, but hope it helps someone coming across the same problem.

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>
    );
}

@ewazgorzelska
Copy link

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

@leonbubova
Copy link

leonbubova commented Jul 4, 2022

In my case I had the option assetPrefix: "./" in my next.config.js to fix an error with the next export command. That was what triggered the behaviour for me. After removing it, hot reload and page refresh worked again.

@co-bby
Copy link

co-bby commented Jul 14, 2022

if you are on windows make sure to install npm on PowerShell, not on WSL

ChubaOraka added a commit to ChubaOraka/aliascheck that referenced this issue Aug 6, 2022
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/
ChubaOraka added a commit to ChubaOraka/aliascheck that referenced this issue Aug 6, 2022
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
ChubaOraka added a commit to ChubaOraka/aliascheck that referenced this issue Aug 6, 2022
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/
ChubaOraka added a commit to ChubaOraka/aliascheck that referenced this issue Aug 6, 2022
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
ChubaOraka added a commit to ChubaOraka/aliascheck that referenced this issue Aug 21, 2022
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/
ChubaOraka added a commit to ChubaOraka/aliascheck that referenced this issue Aug 21, 2022
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
@njfix6
Copy link

njfix6 commented Sep 27, 2022

This also broke for me after upgrading to next 12.0.4 and react 18.2.0

@njfix6
Copy link

njfix6 commented Sep 27, 2022

Confirmed this broke after updating from react 17.0.2 to 18.2.0. Downgrading to 17.0.2 fixes the issue.

@cdrice23
Copy link

Okay.. so for me it was a very silly issue - I had a component nested in a folder controls but I was referencing it from another component as from ./Controls. The casing was the issue - however, everything was rendering / displaying as normal (just no fast refresh), and there were no warnings in the console. I received a warning only after I took a child component in controls and rendered it directly from the component further up the tree. I understand these are separate issues, but just in case someone stumbles across this: casing matters for Fast Refresh (but not always for the build), and if it's nested - it may swallow the warning.

I swear it took me hours of combing through my code and it turns out it was this silly issue as well 😅

@mybuddymichael
Copy link

Edit: Turns out it wasn't relevant to this issue, I somehow never learned I should declare components using <Component/> instead of { Component() }. Rookie mistake, but hope it helps someone coming across the same problem.

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 (Component(props)) instead of as JSX (<Component prop1=…>). Thank you for pointing this out, @yan3321! I was pulling my hair out on this one! 😄

@Frontend-io
Copy link

Disabling webpack5 in next.config solved my issue.

{
  //...
  webpack5: false
}

@vishaalhere
Copy link

Okay.. so for me it was a very silly issue - I had a component nested in a folder controls but I was referencing it from another component as from ./Controls. The casing was the issue - however, everything was rendering / displaying as normal (just no fast refresh), and there were no warnings in the console. I received a warning only after I took a child component in controls and rendered it directly from the component further up the tree. I understand these are separate issues, but just in case someone stumbles across this: casing matters for Fast Refresh (but not always for the build), and if it's nested - it may swallow the warning.

I swear it took me hours of combing through my code and it turns out it was this silly issue as well 😅

Damnnnnnnn!!!! It Worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

No branches or pull requests