-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fast Refresh not working with hooks returning JSX/TSX #354
Comments
This is a duplicate of #289, but thanks for the small repro I'll look into it I didn't though it was that easy to trigger |
if i'm not mistaken, plan uses the regular expression if (tsRE.test(id) && !id.endsWith('.tsx')) {
const hasJsx = jsxContentRE.test(code)
if (hasJsx) {
this.warn(
`File ${id} contains JSX but has a .ts extension. ` +
`Consider renaming to .tsx or adding "// @jsx" pragma comment.`,
)
}
} now, when using hooks with jsx in cc @ArnaudBarre |
The issue is about having correct JSX configure or about file extensions. The code in the issue should correctly get handled but it's not due to how fast refresh works (I think it's possible to do fast refresh for hooks only, but I never correctly implemented it, and it creates this annoying warning). |
then here we need to add a check for the presence of
its just that this check doesnt cover all the cases i think |
The issue is not detecting is the file is JSX, the issue is correctly detecting if the file should be HMRed. |
Describe the bug
We are frequently using custom hooks that will return rendering callbacks in which we refer to actual tsx components.
Is this a bug, or is there any alternative for defining component-based hooks which doesn't break HMR?
Reproduction
https://stackblitz.com/edit/vitejs-vite-zzqhfn?file=src%2Fhook.jsx
Steps to reproduce
A simple example:
hook.tsx
If you use this hook in a component, and then modify the hook's source code, the following will be printed in the console:
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: