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

[NEXT-369] Fast refresh doesn't work when importing function with capitalized name #35567

Open
1 task done
IdkMan2Usertive opened this issue Mar 24, 2022 · 8 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Webpack Related to Webpack with Next.js.

Comments

@IdkMan2Usertive
Copy link

IdkMan2Usertive commented Mar 24, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64
Binaries:
Node: 16.14.0
npm: 8.3.1
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.1.1-canary.17
react: 17.0.2
react-dom: 17.0.2

What browser are you using? (if relevant)

Chrome 99.0.4844.83 (Official) (x86_64)

How are you deploying your application? (if relevant)

Not relevant

Describe the Bug

I think that the reproduction repository I have prepared fully describes the bug so please have a look ⬇️ .

  • If we change the description prop in lowercasedEnhancePropsFunction function HMR will properly refresh the component with the updated data.

  • But If we change the title prop in CapitalizedEnhancePropsFunction function then nothing will change in our component.

  • Issue occurs only if we have a function with capitalized name, imported from another file and that's the only one export existing in this file. If we export anything else from this file (i.e. export const hack = undefined) HMR will work properly.

Expected Behavior

HMR should refresh the component with the updated data every time, no matter the name of the function we are importing.

To Reproduce

I have created a reproduction repository:

https://github.com/usertive/next-js-issue

  1. yarn dev
  2. Change description in lowercasedEnhancePropsFunction function - works.
  3. Change title in CapitalizedEnhancePropsFunction function - doesn't work.

NEXT-369

@IdkMan2Usertive IdkMan2Usertive added the bug Issue was opened via the bug report template. label Mar 24, 2022
@anthonyespirat
Copy link

same issue here ! 12.1.2

@tholder
Copy link

tholder commented Mar 30, 2022

12.1.2 gives me this problem straight off the bat from a clean create next-app

@tholder
Copy link

tholder commented Mar 30, 2022

Can confirm, in a blank create next-app project with 12.1.2, if you replace pages/index.tsx so function is exported as home rather than Home then fast-refresh works.

@tholder
Copy link

tholder commented Mar 30, 2022

12.1.3-canary.4 doesn't seem to exhibit this behaviour.

@timneutkens
Copy link
Member

@anthonyespirat @tholder were you using React 18? If so 12.1.3 has solved the issue with Fast Refresh on React 18. Related PR: #35718

@anthonyespirat
Copy link

fix with this downgrade

    "react": "17.0.2",
    "react-dom": "17.0.2",

@IdkMan2Usertive
Copy link
Author

fix with this downgrade

    "react": "17.0.2",
    "react-dom": "17.0.2",

The reproduction I have provided uses 17.0.2 version and it still suffers from this bug.

@jankaifer
Copy link
Contributor

Just reproduced on next@13.1.2-canary.6 with react@18.2.0.

@jankaifer jankaifer added kind: bug Webpack Related to Webpack with Next.js. labels Jan 12, 2023
@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label Jan 12, 2023
@jankaifer jankaifer added linear: next Confirmed issue that is tracked by the Next.js team. and removed linear: next Confirmed issue that is tracked by the Next.js team. labels Jan 12, 2023
@timneutkens timneutkens added linear: next Confirmed issue that is tracked by the Next.js team. and removed linear: next Confirmed issue that is tracked by the Next.js team. labels Jan 12, 2023
@timneutkens timneutkens changed the title Fast refresh doesn't work when importing function with capitalized name [NEXT-369] Fast refresh doesn't work when importing function with capitalized name Jan 12, 2023
@jankaifer jankaifer added linear: next Confirmed issue that is tracked by the Next.js team. and removed linear: next Confirmed issue that is tracked by the Next.js team. labels Jan 13, 2023
@jankaifer jankaifer removed bug labels Apr 6, 2023
@samcx samcx removed the kind: bug label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

6 participants