question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[addon-docs] mdx breaks with expressions as Story name

See original GitHub issue

Describe the bug

When using a Story in mdx, if you use brackets around your text variable like below, then the compiler errors out.

<Preview>
  <Story name={'text'}>
    <Button onClick={action('clicked')}>Hello Button</Button>
  </Story>
</Preview>

To Reproduce

Create MDX file with brackets around the Story name text

Expected behavior

Storybook should compile

possible cause

Error message points to this

https://github.com/storybookjs/storybook/blob/0ee0e2f1869f6565c84a8424b32bc39ee94fab23/addons/docs/src/mdx/mdx-compiler-plugin.js#L45-L48

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mitchellwarrcommented, Jul 3, 2020

The use case is that we would like to be able to keep our linter consistent across all jsx. We have the lint rule for everything being wrapped in curly brackets.

But besides that use case, using curly brackets in jsx is expected and valid behavior. It feels like a bug that this is breaking. I’m not sure if i just missed some important note in the docs pointing out the different behavior though. But i am a little concerned that when someone else in the team goes to make a doc that they keep the same style of jsx we use everywhere else, get this bug, and then not know why its not compiling

0reactions
stale[bot]commented, Aug 24, 2020

Hey there, it’s me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MDX - Storybook
MDX -defined stories are identical to regular Storybook stories, so they can be used with Storybook's entire ecosystem of addons and view layers....
Read more >
storybook/addon-docs - npm
MDX is a syntax for writing long-form documentation and stories side-by-side in the same file. In contrast to DocsPage , which provides smart ......
Read more >
Storybook Docs with mdx support and addon knobs - Medium
name : '@storybook/addon-docs', // new addon for docs ... If embedding the story directly into a mdx file, the source won't show when ......
Read more >
Disable canvas per story in storybook 6 - Stack Overflow
I don't know if this solution will fit your needs, but the workaroud I found was to write my stories in .mdx and...
Read more >
@storybook/addon-docs | Yarn - Package Manager
how to introduce significant new features (e.g. vue support, story hierarchy)?; how to converge on key design decisions (e.g. new addons API)?; how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found