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

Story source incorrectly rendered as "MDXCreateElement" #16999

Closed
robcaldecott opened this issue Dec 13, 2021 · 4 comments
Closed

Story source incorrectly rendered as "MDXCreateElement" #16999

robcaldecott opened this issue Dec 13, 2021 · 4 comments

Comments

@robcaldecott
Copy link

Describe the bug
Note that this issue relates to #12596 (which has been closed.)

When using an MDX story, certain decorators will incorrectly render the template component as MDXCreateElement.

image

import { Meta, Story, Canvas } from "@storybook/addon-docs";
import { IntlProvider } from "react-intl";
import { Button } from "./Button";

<Meta title="Button MDX" component={Button} />

export const Template = (args) => <Button {...args} />;

<Canvas withSource="open">
  <Story name="Works" args={{ primary: true, label: "Code example works" }}>
    {Template.bind({})}
  </Story>
</Canvas>

<Canvas withSource="open">
  <Story
    name="No Display Name"
    args={{ primary: true, label: "No Display Name" }}
    decorators={[
      (Story) => (
        <IntlProvider locale="en">
          <Story />
        </IntlProvider>
      ),
    ]}
  >
    {Template.bind({})}
  </Story>
</Canvas>

<Canvas withSource="open">
  <Story
    name="Story function"
    args={{ primary: true, label: "MDXCreateElement" }}
    decorators={[(Story) => <IntlProvider locale="en">{Story()}</IntlProvider>]}
  >
    {Template.bind({})}
  </Story>
</Canvas>

In this example I am using react-intl IntlProvider as a decorator. Without this it works (i.e. using a div is fine as long as you call Story() instead of rendering as <Story />.

To Reproduce
https://github.com/robcaldecott/storybook-display-name

System

Environment Info:

  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v14.17.0/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
  Browsers:
    Chrome: 96.0.4664.93
    Firefox: 92.0.1
    Safari: 14.1.2
  npmPackages:
    @storybook/addon-actions: ^6.4.9 => 6.4.9 
    @storybook/addon-essentials: ^6.4.9 => 6.4.9 
    @storybook/addon-links: ^6.4.9 => 6.4.9 
    @storybook/node-logger: ^6.4.9 => 6.4.9 
    @storybook/preset-create-react-app: ^3.2.0 => 3.2.0 
    @storybook/react: ^6.4.9 => 6.4.9
@stale
Copy link

stale bot commented Jan 9, 2022

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jan 9, 2022
@Ponjimon
Copy link

Bump

@maneike
Copy link

maneike commented May 16, 2022

Excluding decorators from the source code did it for me.

 docs: {
          source: {
            type: 'dynamic',
            excludeDecorators: true,
          },
        },

#12022 (comment)

@shilman
Copy link
Member

shilman commented Jun 8, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:

@shilman shilman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants