-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
MDX compilation error: Adjacent JSX elements must be wrapped #10367
Comments
I think you just need to add newlines: import { Meta, Story, Preview } from "@storybook/addon-docs/blocks";
<Meta title="MDX/Sanitize" />
<Preview>
<Story name="sanitize header">
<ce-sanitize html="<h1>Header</h1>"></ce-sanitize>
</Story>
</Preview> |
So the blank lines got me a little further (I had to turn off FormatOnSave in my editor to add them, but whatever). I now have the following .mdx:
that produces the following error:
|
Aha, I didn't see that it's web-components. You need to put quotes around your WC code. Examples: https://raw.githubusercontent.com/storybookjs/storybook/next/examples/web-components-kitchen-sink/stories/addon-docs.stories.mdx |
Weirdly, attempting to use lit-html's html directive resulted in a plethora of new errors. However, just returning the HTML needed for my embedded stencil component as a string worked just fine. The component properly instantiated, and functioned normally. Thanks for working with me on this. The blank line problem was bizarre and very frustrating, but I understand you are still working out the details. Feel free to close this, I can (more or less) get MDX files working to a satisfactory degree. |
I think the blank like thing is a "feature" of MDX itself and nothing todo with storybook's implementation of it, but haven't confirmed. Would be nice if we could give better error messages. At any rate, glad you got it working! |
Thanks. So after a little playing, I can return a node from document.createElement, or I can return a string containing the component I need. But I cannot return something that requires JSX compilation. As far as function, as long as I can use document.createElement, I'm OK because I can add event listeners and the like in my story. But the ability to use JSX would be SO MUCH BETTER. I can use JSX in my CSF / storiesOf stories by having an |
@RaviDesai can you elaborate and share examples? it will help me understand/answer your question. thanks! |
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! |
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! |
The example at docs.stories.mdx is a dead link :( |
I am seeing now same problem in VSCODE after following this guide: I know this is not related to storybook probably, but only putting it here for others to know this issue exists (as of "now") Update (with fix):After digging around for hours, (reading countless random Github issues and Stackoverflow pages) I've landed on the correct Github discussion which enlightened me. I have installed So, in {
"files": ["*.mdx"],
"extends": "plugin:mdx/recommended"
} Then Eslint will stop bother you with JSX-specific issues for |
Describe the bug
Trying to compile any component.stories.mdx file in 5.3.18 fails with the following error in build-storybook:
To Reproduce
Steps to reproduce the behavior:
./node_module/.bin/build-storybook
Expected behavior
The MDX story is added to the storybook
Code snippets
My main.js looks like this:
My webpack.js looks like this:
I have a .babelrc that looks like this:
The story I'm compiling - sanitize.stories.mdx looks like this:
System:
Environment Info:
System:
OS: macOS 10.15.4
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Binaries:
Node: 10.17.0 - /usr/local/bin/node
Yarn: 1.2.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Browsers:
Chrome: 80.0.3987.163
Firefox: 72.0.1
Safari: 13.1
npmPackages:
@storybook/addon-actions: ^5.3.18 => 5.3.18
@storybook/addon-docs: ^5.3.18 => 5.3.18
@storybook/addon-events: ^5.3.18 => 5.3.18
@storybook/addon-knobs: ^5.3.18 => 5.3.18
@storybook/addon-notes: ^5.3.18 => 5.3.18
@storybook/addon-viewport: ^5.3.18 => 5.3.18
@storybook/html: ^5.3.18 => 5.3.18
@storybook/web-components: ^5.3.18 => 5.3.18
Additional context
I know JSX files will produce this error since you always need an outer wrapper for HTML elements with those. But that limitation makes no sense for MDX files. Is there a configuration I'm missing somewhere to allow for this?
The text was updated successfully, but these errors were encountered: