Storybook 中的默认道具值不正确
Default props values in Storybook are not correct
如果我想在 React Storybook 中使用组件 属性 的默认值,这是行不通的。但是,在 React 项目中没有问题。
例如,如果我有一个 Button
组件:
import React from "react";
const objs = { a: "a", b: "b" };
export const Button = ({ testProp = Object.keys(objs), text }) => {
console.log({ objs });
return <button>{text}</button>;
};
testProp
值是一个数组,这是 correct。
这在 Storybook 中不起作用,其中 testProp
值为 string
我不确定是否需要更改某些配置,或者这是 Storybook 中的一个问题。
我刚发现这是故事书bug。
如果我想在 React Storybook 中使用组件 属性 的默认值,这是行不通的。但是,在 React 项目中没有问题。
例如,如果我有一个 Button
组件:
import React from "react";
const objs = { a: "a", b: "b" };
export const Button = ({ testProp = Object.keys(objs), text }) => {
console.log({ objs });
return <button>{text}</button>;
};
testProp
值是一个数组,这是 correct。
这在 Storybook 中不起作用,其中 testProp
值为 string
我不确定是否需要更改某些配置,或者这是 Storybook 中的一个问题。
我刚发现这是故事书bug。