mdx icon indicating copy to clipboard operation
mdx copied to clipboard

do not add empty object `= {}` as default `props`

Open dimaMachina opened this issue 1 year ago • 4 comments

Initial checklist

Problem

I saw in the generated code an empty object as default props props = {}, this is unneeded as props are always object

export default function MDXContent(props = {}) {
image

Solution

export default function MDXContent(props) {

Alternatives

no alternative

dimaMachina avatar Oct 19 '24 10:10 dimaMachina

this is unneeded as props are always object

Who defines that?

I think it’s not needed when used as <MDXContent />. But some people don’t do that. Some people do MDXContent()

wooorm avatar Oct 19 '24 10:10 wooorm

But some people don’t do that. Some people do

if they do it, they can do MDXContent({}) 😅

dimaMachina avatar Oct 19 '24 11:10 dimaMachina

Also React always passes an object as props. Other JSX frameworks might not.

remcohaszing avatar Oct 19 '24 13:10 remcohaszing

People can indeed do MDXContent({}). And that’s probably good. But. Now people don’t have to. And indeed: what about other frameworks. I personally don’t think it’s worth a breaking change. For what benefit? And I worry about those frameworks.

wooorm avatar Oct 19 '24 15:10 wooorm

And indeed: what about other frameworks.

preact definitely should follow React convention, I guess their behaviour should be similar, about other frameworks, idk

For what benefit?

why do specify something that is technically is never will be used, to save some bytes too 😂

dimaMachina avatar Oct 20 '24 09:10 dimaMachina

Hi team! Could you describe why this has been marked as wontfix?

Thanks, — bb

github-actions[bot] avatar Oct 20 '24 16:10 github-actions[bot]

I would agree with this if it was just a React component, but MDX can be used in various ways.

Feel free to create your own recma plugin if you really want to remove the default argument

remcohaszing avatar Oct 20 '24 16:10 remcohaszing