-
-
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
Invalid hook call when using react class component in MDX #2449
Comments
Sounds a lot like #2444? |
The exceptions from #2444 and the one I experience look a bit different. Seems I messed up things a bit on cross-posting. The error thrown in Docusaurus for me is:
But the root cause could still be the same if there is some error handling in place which might change the message seen. From what I understand is:
It's not visible in my demo code but I am using class components because I currently use things like Funnily things work if I move the component into an own TSX file and import it to the MDX. |
See also facebook/docusaurus#9905 (comment) |
done :) |
Initial checklist
Affected packages and versions
@mdx-js/react 3.0.1
Link to runnable example
No response
Steps to reproduce
I reproduced this problem faily easily with Docusaurus as explained here:
The answer of Josh shows how to reproduce the probelm using mdx-js loader. They sent me over to you as it seem the root cause sits in mdx-js.
Expected behavior
It should be possible declare React class components in MDX files without errors.
Actual behavior
When you try to declare react components using React.Component in MDX files you end up with an Invalid hook call. error.
docs/tutorial-basics/markdown-features.mdx
Runtime
Node v20
Package manager
npm v10
OS
Windows
Build and bundle tools
Docusaurus
The text was updated successfully, but these errors were encountered: