storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
83.77k stars 9.18k forks source link

[Bug]: #23423

Open dhanashriz opened 1 year ago

dhanashriz commented 1 year ago

Describe the bug

Integrating Mui-base Menu in the storybook throws an error: The compound component's child doesn't have a key. You need to provide a missingKeyGenerator to generate it. Screenshot 2023-07-12 at 3 55 38 PM

To Reproduce

  1. Created a Menu component with exact same code as: https://codesandbox.io/s/c3h75q?file=/demo.tsx:0-5533
  2. Added below story: `import { Menu } from "../Components"; import type { Meta, StoryObj } from '@storybook/react';

const meta: Meta = { title: 'Components/Menu', component: Menu, tags: ['autodocs'], }

export default meta; type Story = StoryObj;

export const Primary: Story = { args: { }, };`

System

Environment Info:

  System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 15.6.1
  npmPackages:
    @storybook/addon-controls: ^7.0.20 => 7.0.20 
    @storybook/addon-essentials: ^7.0.4 => 7.0.4 
    @storybook/addon-interactions: ^7.0.4 => 7.0.4 
    @storybook/addon-links: ^7.0.4 => 7.0.4 
    @storybook/blocks: ^7.0.4 => 7.0.20 
    @storybook/manager-api: ^7.0.20 => 7.0.20 
    @storybook/preset-create-react-app: ^7.0.4 => 7.0.4 
    @storybook/react: ^7.0.4 => 7.0.18 
    @storybook/react-webpack5: ^7.0.4 => 7.0.4 
    @storybook/testing-library: ^0.0.14-next.2 => 0.0.14-next.2

Additional context

No response

shilman commented 1 year ago

What happens if you use the UnstyledMenuSimple as your component? Is it possible that MUI Menu is not meant to be used on its own without any extra props or children?

dhanashriz commented 1 year ago

Hey @shilman Thanks for the quick response! If I use UnstyledMenuSimple as a component, I can see the Menu loading in the same way as the code sandbox output. MUI doesn't need any keys to be added. But the storybook throws an error for required keys