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
- 🚨
@mdx-js/tag
is replaced by@mdx-js/react
and anmdx
pragma 🚨 - MDXProvider now merges component contexts when nested
- React support now requires
>= 16.8
in@mdx-js/react
Pragma
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 componen
mapping passed to MDXProvider.
So, the following will result in two identically rendered h1
s:
# 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.