-
Consider this code, which is a slightly modified version of the example on the package front page: import React from 'react';
import MDX from '@mdx-js/runtime';
import { MDXProvider } from '@mdx-js/react';
const components = {
Demo: props => <h1>This is a demo component</h1>
}
const mdx = `
# Hello, world!
<Demo />
`
export default () => {
return (
<MDXProvider components={components}>
<MDX>
{mdx}
</MDX>
</MDXProvider>
);
} when run, I see
My questions: am I using Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
godmar
Jan 8, 2022
Replies: 1 comment
-
As per this comment it turns out that import React from 'react';
import * as runtime from 'react/jsx-runtime.js'
import * as provider from '@mdx-js/react'
import {evaluateSync} from '@mdx-js/mdx'
import { MDXProvider } from '@mdx-js/react';
const components = {
Demo: props => <h1>This is a demo component from the provider</h1>
}
const mdx = `
# Hello, world!
<Demo />
`
export default () => {
const {default: Content} = evaluateSync(mdx, {...provider, ...runtime})
return (
<MDXProvider components={components}>
<Content />
</MDXProvider>
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
godmar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As per this comment it turns out that
MDX
and@mdx-js/runtime
are deprecated (and apparently work differently in v2). The correct version is something like:Source: …