Open drunkenvalley opened 1 year ago
I was having the same issue, with components that require a HTML id attribute to function. But now that passing children to Canvas is deprecated, I don't think this will be changed.
I solved it by adding the TestComponent story to an adjacent file and importing it. Eg:
// test.stories.tsx
import type { Meta } from '@storybook/react';
import { TestComponent } from '.';
const meta: Meta<typeof TestComponent> = {
component: TestComponent,
};
type Story = StoryObj<typeof TestComponent>;
export const Basic: Story = {
// can add id here with no problem
render: () => <TestComponent id="testComponent" />,
};
export default meta;
// test.mdx
import { Canvas, Meta } from '@storybook/addon-docs';
import * as stories from './test.stories.tsx'
<Meta title="Test Component" />
# Test Component
<Canvas of={stories.Basic} />
Describe the bug
I have some
.mdx
files describing the HTML for a component. The first element has anid
, and it is mistakenly interpreted to be referring to a story id.To Reproduce
https://stackblitz.com/edit/github-qwj9m6?file=src/stories/test.mdx
id
to the first HTML elementThere is no error produced initially, but when trying to load the page it will spin forever, failing to load.
Example:
System
Additional context
I tried to create a Stackblitz with HTML + Vite, but it failed on installing dependencies. Should I file that as a separate issue?