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

feature request: Allow lazy loading #40

Open
januswel opened this issue Apr 10, 2024 · 4 comments
Open

feature request: Allow lazy loading #40

januswel opened this issue Apr 10, 2024 · 4 comments

Comments

@januswel
Copy link

Now, the rule raises errors with the following codes

const LazyComponent = React.lazy(
  () => import("./MyComponent"),
);
Fast refresh only works when a file only exports components. Move your component(s) to a separate file.eslint(react-refresh/only-export-components)

Can we modify to determine this as the correct code?

@ArnaudBarre
Copy link
Owner

Can you give more context? This code creates a component so it should follow some Fast refresh rules

@januswel
Copy link
Author

I made a repo to repro

https://github.com/januswel/react-refresh-sample

image

This problem may occur with RouteObjects react-router v6

@ArnaudBarre
Copy link
Owner

This is the same issue as #25

I need to dig deeper to see how it really behaves at runtime. Given that SWC and Babel generate some fast refresh code for that for now it's safer to consider that React.lazy calls are like creating a wrapper component (which is the case)

@januswel
Copy link
Author

@ArnaudBarre
Thank you for your comment
I saw #25 and consider to use workarounds from you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants