-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
MDX and React instructions don't work for TypeScript projects #7047
Comments
@kaycebasques Do you have a reproduction? If anything goes against the documentation you'd better give something so we can investigate, as I'm sure not everyone's running into this. |
Repro
(Note there is no TypeScript information in that guide)
ResultFixFollow the example of the
(This fix sections summarizes the changes I'm proposing to MDX and React... there should probably be an H3 section after importing components dedicated to the TS workflow) |
Hi, you need to There are many ways to enforce this, for example, there's the ESLint rule: https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/react-in-jsx-scope.md When you use TS, TS will also warn you about React not being in scope when using JSX. Since this is only about JSX and not about Docusaurus, I will close this. |
Thanks for taking the extra time to link to those docs and explain. Since I'm new to React I understand I may not be your target audience but perhaps a fix here is to just add the import statement to the top of the |
Oh, I just realized our docs don't add that import statement 🤦♂️ Happy to have a PR that adds import React for that! |
Have you read the Contributing Guidelines on issues?
Description
After following these instructions: https://docusaurus.io/docs/markdown-features/react#importing-components
Docusaurus would tell me that the page crashed and that React is undefined.
I eventually had a hunch that it was because I had initialized my Docusaurus project with TypeScript. Perhaps it's obvious to seasoned TS developers but I'm still new to it.
I think I can take on this documentation update myself but I'm creating this issue in case I get sidetracked.
Self-service
The text was updated successfully, but these errors were encountered: