-
Notifications
You must be signed in to change notification settings - Fork 16
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
unexported (non-component) constant triggers warning #75
Comments
The rule is enaled only in JSX/TSX files, so not exporting a function that matches React component naming (
|
In my actual case, the file has no actual React component in it, but the
I can easily shush the warning by just changing |
Why can't getFoo be a Foo/DisplayFoo component? That's true that this file won't break HMR, because it can't self self update in the first place, this pattern is kind of unsupported but could be without too much work I think, let me check |
The code for local variables was not using the same checks as for exported variables. I'll try to fix the type issue reported by the TS team and published a version |
Yeah ... in this case you're right, that should just be a component. My real code has a lot more going on but boils down to the same issue here. I don't think it's worth getting into the details, but my real
So, definitely not a component. But I end up doing this a lot, actually, writing helper methods that contain JSX. I've never had any issues with it but also haven't stopped to think about how that might impact HMR. |
In that case the impact on HMR is the same as any util function, when updating this file it will refresh all the components that imports it. If you want a better understanding, you can look at my talk at Vite conf 2023: https://www.youtube.com/watch?v=woVquKjLs1M The version was published btw |
I have a file like this:
This triggers the
Fast refresh only works when a file only exports components
warning. Lowercasing fixes the problem, or putting an underscore inside the variable name:In any case I'm not exporting
FOO
... should this trigger the warning?The text was updated successfully, but these errors were encountered: