Skip to content

Shortcodes breaks if same component if used more than once #518

@alexandernanberg

Description

@alexandernanberg

Subject of the issue

Shortcodes breaks if same component if used more than once. We probably want to add a check if the makeShortcode is already added or not.

Your environment

@mdx-js/mdx@1.0.2
@mdx-js/react@1.0.2

Steps to reproduce

<Foo bg='red'>
  <Bar>hi</Bar>
  {hello}
  {/* another commment */}
</Foo>

<Foo bg='red'>
  <Bar>hi</Bar>
</Foo>

Expected behaviour

Should work without errors

Actual behaviour

SyntaxError: unknown: Identifier 'Foo' has already been declared (17:6)

      15 | const Foo = makeShortcode("Foo");
      16 | const Bar = makeShortcode("Bar");
    > 17 | const Foo = makeShortcode("Foo");
         |       ^
      18 | const Bar = makeShortcode("Bar");
      19 | const layoutProps = {
      20 |   foo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions