-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Bug: [Refresh] Default exported unnamed functions are ignored #21181
Comments
This is intentional — even if we fix this case, we need some heuristic for other tools like lint rules. Why are you using this style? Functions should have names so that you get them in stack traces and so on. |
Indeed, but then it becomes confusing: vitejs/vite-plugin-react#20. If there's no way around, this can be closed and I'll make a suggestion downstream to use https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md. The code comment mentioned above should then also be more explicit, replacing "currently" by "intentionally". |
However, given that an ignored component prevents a refresh (vitejs/vite-plugin-react#20), I haven't figured out yet whether this is an issue with |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
These though fail. Anon default export: facebook#21181 Promise callbacks: facebook#26186 Returning anon functions: facebook#22520
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
React version: 17.0.2
React-refresh version: 0.10.0
This issue is similar to #21179, but ignores default exported unnamed functions instead.
As a code comment suggests, this is a known limitation:
react/packages/react-refresh/src/ReactFreshBabelPlugin.js
Lines 437 to 438 in a817840
Would a fix be considered?
Steps To Reproduce
Given the following files, making changes to
Component.js
doesn't trigger a re-render.main.js
module:Component.js
module:The current behavior
Making changes to
Component.js
does not re-render the element inmain.js
.The transformed
Component.js
module does not register theComponent
for refresh.The expected behavior
Making changes to
Component.js
does re-render the element inmain.js
.The text was updated successfully, but these errors were encountered: