Skip to content

Commit 680445d

Browse files
authoredOct 25, 2023
Add note on broken react runtime types
Closes GH-2383. Reviewed-by: Titus Wormer <tituswormer@gmail.com>
1 parent 850155e commit 680445d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎docs/migrating/v3.mdx

+14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ You will get a runtime error if these features are used in MDX without
5252
If you passed the `useDynamicImport` option before, remove it, the behavior
5353
is now the default.
5454

55+
If you use `react/jsx-runtime`, you might get a TypeScript error (such as
56+
`Property 'Fragment' is missing in type`), because it is typed incorrectly.
57+
To remediate this, do:
58+
59+
```tsx
60+
import {type Fragment, type Jsx, run} from '@mdx-js/mdx'
61+
import * as runtime_ from 'react/jsx-runtime'
62+
63+
// @ts-expect-error: the automatic react runtime is untyped.
64+
const runtime: {Fragment: Fragment; jsx: Jsx; jsxs: Jsx} = runtime_
65+
66+
const result = await run('# hi', {...runtime, baseUrl: import.meta.url})
67+
```
68+
5569
## Use the automatic JSX runtime
5670

5771
If you use the classic runtime, switch to the automatic runtime.

1 commit comments

Comments
 (1)

vercel[bot] commented on Oct 25, 2023

@vercel[bot]

Successfully deployed to the following URLs:

mdx – ./

mdxjs.com
mdx-git-main-mdx.vercel.app
mdx-mdx.vercel.app
v2.mdxjs.com

Please sign in to comment.