Skip to content
🎉MDX Conf — August 24th, 2020
MDX logo
v2.0.0-next.9

Migrating from v0 to v1

Unfortunately, we’ve had to introduce a few breaking changes, so we’ve written a migration guide. In order to ensure as seamless of an upgrade as possible we plan on supporting v0 for the next 12 months so there’s not a huge rush to update (though we’d love for you to ASAP) 📆.

⚠️ Breaking changes

Pragma

For v1 you need to remove @mdx-js/tag and replace it with @mdx-js/react:

yarn remove @mdx-js/tag
yarn add @mdx-js/react

What’s different?

The MDXTag implementation has been removed with a custom pragma implementation inspired by Emotion. This ensures that transpiled JSX is more readable and that JSX blocks use the same component as its markdown counterpart. It also allows MDXProvider to provide global component scope like a Youtube or Twitter component.

The pragma implementation will also cause JSX HTML elements to be rendered with the component mapping passed to MDXProvider. So, the following will result in two identically rendered h1s:

# Hello, world!

<h1>Hello, world!</h1>

See the blog post for further reading

MDXProvider

This shouldn’t affect most usecases, however if you’re nesting component contexts and rely on them not being merged you will have to use the functional form which allows you to customize the merge. By ignoring outer context components and returning a new component mapping, you will restore the old behavior:

<MDXProvider components={components}>
  <MDXProvider components={outerComponents => newComponents}>
    {children}
  </MDXProvider>
</MDXProvider>

React

Before upgrading to @mdx-js/mdx@1, update your website/application to react@16.8 react-dom@16.8 and ensure it works as expected. Then upgrade to v1.

Edit this page on GitHub