Skip to content

Remove useMDXComponents argument #80871

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

Open
wants to merge 3 commits into
base: canary
Choose a base branch
from

Conversation

remcohaszing
Copy link
Contributor

What?

Fix the signatures of useMDXComponents.

Why?

The useMDXComponents function is always called without any arguments. It’s also always supposed to be a named export, not a default export. It’s also called during render. Defining React components during render is an anti-pattern. All components that were previously defined inside of useMDXComponents, are now defined outside of the function.

How?

Manual fixes.

The `useMDXComponents` function is always called without any arguments.
It’s also always supposed to be a named export, not a default export.
It’s also called during render. Defining React components during render
is an anti-pattern. All components that were previously defined inside
of `useMDXComponents`, are now defined outside of the function.
@ijjk ijjk added Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template. tests type: next labels Jun 24, 2025
@ijjk
Copy link
Member

ijjk commented Jun 24, 2025

Allow CI Workflow Run

  • approve CI run for commit: a2b4c8e

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@ijjk
Copy link
Member

ijjk commented Jun 24, 2025

Allow CI Workflow Run

  • approve CI run for commit: a53c31d

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
@icyJoseph icyJoseph self-assigned this Jun 25, 2025
@icyJoseph
Copy link
Contributor

The e2e files you removed are related to the other PR where we use a default mdx-components.tsx file right? Since that's in now, the e2e tests don't need to define a mock, is that why? I guess test/integration/plugin-mdx-rs/mdx-components.js is enough to still make sure that it still works when users define it on their directory.

@remcohaszing
Copy link
Contributor Author

Correct. Those files are redundant now. I’ll gladly restore them if desirable, but they don’t add any value anymore.

@icyJoseph
Copy link
Contributor

Correct. Those files are redundant now. I’ll gladly restore them if desirable, but they don’t add any value anymore.

Nah, I think test/integration/plugin-mdx-rs/mdx-components.js is enough

return {
...components,
}
const components = {} satisfies MDXComponents
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with what we have further down too, or vice versa, but let's stick to one

Suggested change
const components = {} satisfies MDXComponents
const components: MDXComponents = {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template. tests type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants