-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
react hmr (fast refresh) breaks when deleting all content of a mdx file #2444
Comments
Welcome @csr632! Could you explain how you see this as as breaking the rule of hooks?
This call you reference is:
It doesn't feel like a violation of the rule of hooks. |
Hi @ChristianMurphy ! The other hook rule it violates is that, |
Ah yes, I see the problem. A very similar problem happens when the value of Hooks may only be called from other hooks (function starting with The solution is as @csr632 proposes, to change the |
If the user provides a `wrapper` component, `_createMdxContent` was treated as a JSX component. Otherwise it was invoked as a function. Because `_createMdxContent` uses a hook, this hooks becomes part of the `MDXContent` component conditionally. This breaks React’s rule of hooks. Closes #2444
Initial checklist
Affected packages and versions
3.0.1
Link to runnable example
https://stackblitz.com/edit/vitejs-vite-sorj9w?file=src%2Ftest.mdx,vite.config.ts&terminal=dev
Steps to reproduce
npm run dev
if it is not auto run)test.mdx
Expected behavior
The app should not be broken.
Actual behavior
The app is broken.
Runtime
Node v20
Package manager
npm v10
OS
macOS
Build and bundle tools
Vite
The text was updated successfully, but these errors were encountered: