Skip to content

Doesn't work with "autodocs" tags #225

@codemile

Description

@codemile

If you're running Storybook v8 with the "autotags" to generate a MDX document of all your stories, then it uses the wrong mocks for each story.

Reference: https://storybook.js.org/docs/writing-docs/autodocs

In the following example, the autotags is used to render both the FirstStory and the SecondStory on the page, and the SecondStory will receive the mocks from FirstStory. This only happens on the autotags page, when viewing the stories individually it works fine.

export default {
    title: 'Example',
    component: MyExample,
    tags: ['autodocs'],
    // ^^^ enable autodocs feature
} satisfies Meta<typeof MyExample>;

type Story = StoryObj<typeof MyExample>;

export const FirstStory: Story = {
    parameters: {
        mockData: [
             // *** mock some stuff
        ]
    }
};

export const SecondStory: Story = {
    parameters: {
        mockData: [
             // *** mock some stuff
        ]
    }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions