-
Context
Question I met
Hello, world!
export default function NextraPage (props) {
return <div>Just for demo</div>
} This generated mdx code as below: /*@jsxRuntime automatic @jsxImportSource react*/
const {jsx: _jsx} = arguments[0];
const MDXLayout = function NextraPage(props) { // HERE: This is the props we can manage
return _jsx("div", {
children: "Just for demo"
});
};
function MDXContent(props = {}) {
return MDXLayout ? _jsx(MDXLayout, Object.assign({}, props, {
children: _jsx(_createMdxContent, {})
})) : _createMdxContent();
function _createMdxContent() {
const _components = Object.assign({
p: "p"
}, props.components); // HERE: the props is from **MDXContent** function not MDXLayout, in `nextra`/`next.js`, if you visit /pages/my-mdx.mdx , you can not pass props to **MDXContent** directly
return _jsx(_components.p, {
children: "Hello, world!"
});
}
}
return {
default: MDXContent
}; Thoughtswould this prototype work
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I don’t really understand the problem, you could create a factory function that gets props that wraps layouts? |
Beta Was this translation helpful? Give feedback.
-
much appreciated @wooorm for checking and helps!
yep that's true, I am just start learning those these days, let me dig more, this seems more be |
Beta Was this translation helpful? Give feedback.
MDXProvider
is not deprecated. But it’s often not needed. More in the docs: https://mdxjs.com/docs/using-mdx/#mdx-provider.children
here instead of a component). We don’t do that, other frameworks don’t do that. It’s a conscious decision by Next.js that prevents you from passing stuff, and we can’t get around it.example.
I don’t really understand the problem, you could create a factory function that gets props that wraps layouts?
I don‘t understand you…