storybook
storybook copied to clipboard
[Bug]: `Cannot convert object to primitive value` when passing Modules in args
Describe the bug
When passing a Module to an arg in a CSF story like this:
import { Description } from './Description';
import * as DefaultButtonStories from '../examples/Button.stories'; // 👈
const meta = {
component: Description,
};
export default meta;
export const OfMetaAsComponentComment = {
args: {
of: DefaultButtonStories, // 👈
}
};
The story crashes with Cannot convert object to primitive value
:
Cannot convert object to primitive value
TypeError: Cannot convert object to primitive value
at http://localhost:6006/sb-preview/runtime.mjs:8814:34
at Array.reduce (<anonymous>)
at undecoratedStoryFn (http://localhost:6006/sb-preview/runtime.mjs:8812:53)
at http://localhost:6006/sb-preview/runtime.mjs:6111:21
at http://localhost:6006/sb-preview/runtime.mjs:8704:12
at jsxDecorator (http://localhost:6006/node_modules/.cache/.vite-storybook/deps/@storybook_react_preview.js?v=ce6491e8:1862:17)
at http://localhost:6006/sb-preview/runtime.mjs:6111:21
at http://localhost:6006/sb-preview/runtime.mjs:8679:23
at http://localhost:6006/sb-preview/runtime.mjs:8704:12
at wrapper (http://localhost:6006/node_modules/.cache/.vite-storybook/deps/@storybook_addon-links_preview.js?v=ce6491e8:106:12)
An error that is thrown from here: https://github.com/storybookjs/storybook/blob/7584d9630a55825e5b747291bb506f38ed45d402/code/renderers/react/src/docs/jsxDecorator.tsx#L111-L112
To Reproduce
-
git checkout block-description-improvements
-
cd code
-
yarn storybook:ui
- Comment out the workaround at https://github.com/storybookjs/storybook/blob/7584d9630a55825e5b747291bb506f38ed45d402/code/ui/blocks/src/blocks/Description.stories.tsx#L17
- Navigate to
http://localhost:6006/?path=/story/storybook-blocks-blocks-description--of-meta-as-meta-comment
The source for the stories can be seen here: https://github.com/storybookjs/storybook/blob/7584d9630a55825e5b747291bb506f38ed45d402/code/ui/blocks/src/blocks/Description.stories.tsx
Additional context
This is not a problem if the arg is defined in the meta, only in the story.
Hi @JReinhold , the links you have provided are not working. The specified branch is deleted. Can you please update the issue description and link to the source files you mentioned.
Thanks @AnandChandrakar . Updated