Skip to content

Commit

Permalink
Add note on broken react runtime types
Browse files Browse the repository at this point in the history
Closes GH-2383.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
ky1ejs committed Oct 25, 2023
1 parent 850155e commit 680445d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/migrating/v3.mdx
Expand Up @@ -52,6 +52,20 @@ You will get a runtime error if these features are used in MDX without
If you passed the `useDynamicImport` option before, remove it, the behavior
is now the default.

If you use `react/jsx-runtime`, you might get a TypeScript error (such as
`Property 'Fragment' is missing in type`), because it is typed incorrectly.
To remediate this, do:

```tsx
import {type Fragment, type Jsx, run} from '@mdx-js/mdx'
import * as runtime_ from 'react/jsx-runtime'

// @ts-expect-error: the automatic react runtime is untyped.
const runtime: {Fragment: Fragment; jsx: Jsx; jsxs: Jsx} = runtime_

const result = await run('# hi', {...runtime, baseUrl: import.meta.url})
```

## Use the automatic JSX runtime

If you use the classic runtime, switch to the automatic runtime.
Expand Down

1 comment on commit 680445d

@vercel
Copy link

@vercel vercel bot commented on 680445d Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.