question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fast refresh doesn't work when importing function with capitalized name

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
timneutkenscommented, Mar 31, 2022

@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

1reaction
anthonyespiratcommented, Mar 31, 2022

fix with this downgrade

    "react": "17.0.2",
    "react-dom": "17.0.2",
Read more comments on GitHub >

github_iconTop Results From Across the Web

Reading and writing data to the cache - Apollo GraphQL Docs
Any changes you make to cached data with writeFragment are not pushed to your GraphQL server. If you reload your environment, these changes...
Read more >
Anonymous arrow functions cause Fast Refresh to not ...
As the error message suggests, you need to add a name to the function component you're exporting. const IndexPage = () => <TVChartContainer ......
Read more >
ImportAPI Custom Function | API Connector - Mixed Analytics
Google runs custom functions when the sheet is opened, refreshed, or changed. It may also run functions after a period of inactivity as...
Read more >
Useful script snippets | Tabular Editor Documentation
Here's a collection of small script snippets to get you started using the Advanced Scripting functionality of Tabular Editor. Many of these scripts...
Read more >
The React Handbook – Learn React for Beginners
When you run npx create-react-app <app-name> , npx is going to ... to how it works internally, you don't use the regular ES...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found