mdxJsxFlowElement vs element #1969
-
I am nearly done with an upgrade to MDX v2, congrats on the release and thanks for the great docs to guide me through 🎉 While working through this, there was one thing that caught me enough by surprise that I wanted to check in if it is expected behavior. https://mdxjs.com/playground/ in the MDX playground, insert the following:
Previously, both of these ended up as hast type This is an easy fix: just use |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey Katie! It’s intended that explicit JSX tags can’t be changed but things from markdown can.
Both are paragraphs. But what should happen when a component for Your question shows that there’s something to be said for both explicit JSX and normal markdown to use the same component.
…assuming you change what components you pass and also pass your custom thematic break as
Note: the reason both are treated the same is not that they’re different nodes in mdast/hast.
In short, all of the lowercase things can’t be overwritten. |
Beta Was this translation helpful? Give feedback.
-
Thanks, Titus--this makes a lot of sense! And thanks for the added note re |
Beta Was this translation helpful? Give feedback.
Hey Katie!
It’s intended that explicit JSX tags can’t be changed but things from markdown can.
To illustrate why, take this:
Both are paragraphs. But what should happen when a component for
p
is passed to add a class ofnormal-paragraph
?Chances are that the first one shouldn’t be changed, only the second. This shows that the previous behavior sometimes yielded unexpected results.
Your question shows that there’s something to be said for both explicit JSX and normal markdown to use the same component.
You can be explicit there though:
…assuming you change what components you pass and also pass your custom thematic break as