Raw html in mdx files doesn't defer rendering to _components
#2314
-
I have an MDX file that looks something like this: Hello
<p>Goodbye</p> However, when I serialize the mdx content, only the function _createMdxContent(props) {
const _components = Object.assign({
p: "p"
}, _provideComponents(), props.components);
...
}, this), "\n", _jsxDEV(_components.p, {
children: "Hello"
}
...
}, this), "\n", _jsxDEV("p", { // <-- I want this to be _components.p
children: "Goodbye"
} Is this a bug or expected behavior? Is there a config to get the Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Correct, “normal” components you write in MDX can’t be swapped. You should be able to find more issues discussing this. That’s because JSX already has a mechanism for that: Use a capital (the actual rules are more complex): <P>Something wrapped in my fancy P component</P> Whereas, if we would do what you want, it would be hard/weird to not swap components. Sometimes people want to use their own Some more info in the Components section in the docs! |
Beta Was this translation helpful? Give feedback.
-
Amazing thanks so much! |
Beta Was this translation helpful? Give feedback.
Correct, “normal” components you write in MDX can’t be swapped. You should be able to find more issues discussing this. That’s because JSX already has a mechanism for that: Use a capital (the actual rules are more complex):
Whereas, if we would do what you want, it would be hard/weird to not swap components. Sometimes people want to use their own
MyHeadingComponent
for# this
but not for<h1>this</h1>
.Some more info in the Components section in the docs!