描述bug
当将一个模块传递给CSF故事中的参数时,例如:
import { Description } from './Description';
import * as DefaultButtonStories from '../examples/Button.stories'; // 👈
const meta = {
component: Description,
};
export default meta;
export const OfMetaAsComponentComment = {
args: {
of: DefaultButtonStories, // 👈
}
};
故事会因为 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)
从这里抛出的错误:
storybook/code/renderers/react/src/docs/jsxDecorator.tsx
第111行到第112行 in 7584d96
| | letstring: string=toJSXString(child,optsasOptions); |
| | |
重现问题
git checkout block-description-improvements
cd code
yarn storybook:ui
- 在 storybook/code/ui/blocks/src/blocks/Description.stories.tsx 文件的第17行注解掉解决方法:
| | docs: {source: {type: 'code'}}, | - 导航到
http://localhost:6006/?path=/story/storybook-blocks-blocks-description--of-meta-as-meta-comment
故事的源代码可以在这里查看:
https://github.com/storybookjs/storybook/blob/7584d9630a55825e5b747291bb506f38ed45d402/code/ui/blocks/src/blocks/Description.stories.tsx
其他信息
如果参数在元数据中定义,而不是在故事中,这不是一个问题。
2条答案
按热度按时间kx7yvsdv1#
你好,@JReinhold ,你提供的链接无法使用。指定的分支已被删除。
你能更新问题描述并链接到你提到的源文件吗?
46scxncf2#
感谢@AnandChandrakar。已更新。