Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDX 3.1.0 introduce breaking change - no longer replace mdx components in React components declared in mdx files #2549

Closed
4 tasks done
dimaMachina opened this issue Oct 20, 2024 · 12 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@dimaMachina
Copy link

Initial checklist

Affected packages and versions

@mdx-js/mdx

Link to runnable example

No response

Steps to reproduce

See diff of snapshot
image

Expected behavior

as before or you should cut a new major release

Screen.Recording.2024-10-20.at.04.23.39.mov

Actual behavior

Screen.Recording.2024-10-20.at.04.22.44.mov

Affected runtime and version

node 20

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Oct 20, 2024
@dimaMachina dimaMachina changed the title MDX 3.1.0 introduce breaking change - no longer replace mdx components as functions MDX 3.1.0 introduce breaking change - no longer replace mdx components in scoped functions Oct 20, 2024
@dimaMachina dimaMachina changed the title MDX 3.1.0 introduce breaking change - no longer replace mdx components in scoped functions MDX 3.1.0 introduce breaking change - no longer replace mdx components in React components declared in mdx files Oct 20, 2024
@wooorm
Copy link
Member

wooorm commented Oct 21, 2024

Hi!

I think you mean this patch c747990.
The old behavior was not intentional. The new behavior is intentional. It is assumed that few people depended on it. It broke other people. So, it is considered a patch.

See facebook/docusaurus#9905 (comment) for some more background info.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
@wooorm wooorm added the 🙅 no/wontfix This is not (enough of) an issue for this project label Oct 21, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Oct 21, 2024
@dimaMachina
Copy link
Author

@wooorm Even it was not intentional I am pretty sure there are a lot of folks who relied on it, instead of doing breaking change in minor 3.1 release you could do a release of MDX 4 with this change and drop off old Node.js 16 and require Node.js 18 for example

@remcohaszing what do you think?

@wooorm
Copy link
Member

wooorm commented Oct 22, 2024

I am pretty sure basically nobody uses this. Why do you think many people use this?

What you link to in nextra is not changed. It is not related

What is no longer possible is that you can define a custom component (Test above), write regular JSX in it (span above), and then pass components to change them.

@dimaMachina
Copy link
Author

dimaMachina commented Oct 22, 2024

I am pretty sure basically nobody uses this. Why do you think many people use this?

Because it was an easy way to have reusable component with the same styles applied from providerImportSource

What you link to in nextra is not changed. It is not related

What do you mean? Below MyComponent is now unstyled

// my-mdx-page.mdx
export function MyComponent() {
  return (
    <>
      <table>
        <thead>
          <tr>
            <th>Month</th>
            <th>Savings</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>January</td>
            <td>$100</td>
          </tr>
          <tr>
            <td>February</td>
            <td>$80</td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td>Sum</td>
            <td>$180</td>
          </tr>
        </tfoot>
      </table>
      <h1>h1</h1>
      <h2>h2</h2>
      <h3>h3</h3>
      <h4>h4</h4>
      <h5>h5</h5>
      <h6>h6</h6>
    </>
  )
}

<MyComponent />

@wooorm
Copy link
Member

wooorm commented Oct 22, 2024

I do not know what you mean. What does “unstyled” mean? You can use CSS if you want to style things?
Your issue above is not about style.
The Nextra issue is not about style?
Can you please provide some more info?

@dimaMachina
Copy link
Author

What does “unstyled” mean?

mdx components from providerImportSource no longer injected for html elements in MyComponent component

You can use CSS if you want to style things?

Sure, the issue is that you did significant breaking change in minor release

@wooorm
Copy link
Member

wooorm commented Oct 22, 2024

Your Nextra PR is wrong.

export function Table({ columns, data }) {
  return <table>{/* ... */}</table>
}

<Table columns={3} data={4} />

Has worked and still works. https://mdxjs.com/playground/


I understand that you don’t understand English well. You are mixing different things. That change in your Nextra PR is wrong. It has nothing to do with this. Components are still supported.

@dimaMachina
Copy link
Author

dimaMachina commented Oct 22, 2024

Your Nextra PR is wrong.

export function Table({ columns, data }) {
  return <table>{/* ... */}</table>
}

<Table columns={3} data={4} />

Has worked and still works. mdxjs.com/playground

You are taking this example out of the context of written section. This section explained how to have a styled <table> and not how to use React Components in MDX.

I understand that you don’t understand English well. You are mixing different things. That change in your Nextra PR is wrong. It has nothing to do with this. Components are still supported.

Thank you for pointing out my English 😂, my PR is not wrong, I removed the no longer worked way of having styled <table>.

@wooorm
Copy link
Member

wooorm commented Oct 22, 2024

Jeez. I do not understand why Nextra has this weird guide up.

If you want to pass components, pass components: Span, Table, TableCell.

In JSX, Span is a reference to something. span is not a reference to something. span is span.

This was documented: https://mdxjs.com/docs/using-mdx/#components.

This bug was not intentional. This fix is intentional.

@dimaMachina
Copy link
Author

There is no mention in Nextra’s docs of passing <Table> component somewhere, he was just locally declared in mdx file

@wooorm
Copy link
Member

wooorm commented Oct 23, 2024

That’s the problem. If they passed Table, Td, whatever components they wanted, there are no hacks or workarounds needed, no guide needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants