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

Function as Child Component #485

Closed
4 tasks done
kocobee opened this issue Dec 12, 2024 · 3 comments · Fixed by #486
Closed
4 tasks done

Function as Child Component #485

kocobee opened this issue Dec 12, 2024 · 3 comments · Fixed by #486
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🐛 type/bug This is a problem

Comments

@kocobee
Copy link

kocobee commented Dec 12, 2024

Initial checklist

Affected package

@mdx-js/[email protected]

Steps to reproduce

Create a function as child component w/ some nesting, i.e.

<Foo arr={bleh}>
  {name => 
    <>
      <Bar>
        <Baz>{name}</Baz>
      </Bar>
    </>
  }
</Foo>

Actual behavior

Get a syntax error:

Screenshot 2024-12-12 at 2 20 18 PM Screenshot 2024-12-12 at 2 23 56 PM

Expected behavior

No syntax error

Runtime

No response

Package manager

No response

Operating system

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 Dec 12, 2024
@remcohaszing
Copy link
Member

Thanks for reporting and including a reproduction!

Cross reference: https://github.com/orgs/mdx-js/discussions/2514

@remcohaszing remcohaszing added 🐛 type/bug This is a problem 🗄 area/interface This affects the public interface 🙆 yes/confirmed This is confirmed and ready to be worked on 👍 phase/yes Post is accepted and can be worked on labels Dec 12, 2024
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Dec 12, 2024

This comment has been minimized.

remcohaszing added a commit that referenced this issue Dec 22, 2024
Virtual code generation from estree expressions was based on an
assumption of the order in which JSXIdentifier nodes are visited.
`estree-walker` visits the nodes in property order. The parser generates
AST properties in an order that broke our code generation. As a result,
the string `_components.` was injected in an incorrect position in the
virtual code, yielding syntax errors.

This is now resolved by explicitly handling `JSXElement` nodes in both
the enter and leave methods, instead of just handling `JSXIdentifier`
nodes.

Closes #485
remcohaszing added a commit that referenced this issue Dec 23, 2024
Virtual code generation from estree expressions was based on an
assumption of the order in which JSXIdentifier nodes are visited.
`estree-walker` visits the nodes in property order. The parser generates
AST properties in an order that broke our code generation. As a result,
the string `_components.` was injected in an incorrect position in the
virtual code, yielding syntax errors.

This is now resolved by explicitly handling `JSXElement` nodes in both
the enter and leave methods, instead of just handling `JSXIdentifier`
nodes.

Closes #485

This comment has been minimized.

@remcohaszing remcohaszing added the 💪 phase/solved Post is done label Dec 23, 2024
@github-actions github-actions bot removed 👍 phase/yes Post is accepted and can be worked on 🙆 yes/confirmed This is confirmed and ready to be worked on labels Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🐛 type/bug This is a problem
Development

Successfully merging a pull request may close this issue.

2 participants