描述bug
在storysource中,Template
变量每次使用Template.bind({})
重复一次。其他功能,如点击源代码导航到故事,是损坏的。
重现
使用storybook CLI初始化一个新的storybook并设置{ injectStoryParameters: false }
。
部署示例:https://petermikitsh.github.io/sb-source-error/?path=/story/example-button--primary (转到“故事”选项卡)
源代码: https://github.com/petermikitsh/sb-source-error
预期行为
我期望变量模板只定义一次,并且点击故事的源代码可以导航到故事。
截图
代码片段
storysource“故事”选项卡中显示的基线文件与实际文件之间的差异:
import React from "react";
import { Meta } from "@storybook/react/types-6-0";
import { Button } from "./Button";
// remove 'as Meta' for storysource to work
export default {
title: "Example/Button",
component: Button,
argTypes: {
backgroundColor: { control: "color" },
},
};
const Template = (args) => <Button {...args} />;
+ const Template = (args) => <Button {...args} />;
+ const Template = (args) => <Button {...args} />;
+ const Template = (args) => <Button {...args} />;
export const Primary = Template.bind({});
Primary.args = {
primary: true,
label: "Button",
};
export const Secondary = Template.bind({});
Secondary.args = {
label: "Button",
};
export const Large = Template.bind({});
Large.args = {
size: "large",
label: "Button",
};
export const Small = Template.bind({});
Small.args = {
size: "small",
label: "Button",
};
系统:
$ npx sb@next info
Environment Info:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Binaries:
Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm
Browsers:
Safari: 12.1.2
npmPackages:
@storybook/addon-actions: ^6.0.5 => 6.0.10
@storybook/addon-essentials: ^6.0.5 => 6.0.10
@storybook/addon-links: ^6.0.5 => 6.0.10
@storybook/addon-storysource: ^6.0.5 => 6.0.10
@storybook/react: ^6.0.5 => 6.0.10
@storybook/source-loader: ^6.0.5 => 6.0.10
5条答案
按热度按时间goucqfw61#
大家好!最近似乎没有太多关于这个问题的进展。如果还有问题、评论或错误,请随时继续讨论。遗憾的是,我们没有时间处理每一个问题。我们始终欢迎贡献,所以如果你想帮忙,请发送一个pull request。30天后未活跃的问题将被关闭。谢谢!
jtw3ybtb2#
这个可能值得保留,因为文档鼓励使用
Template.bind({})
语法。sz81bmfz3#
Is there any update on this? This is also creating ugly warning's of duplicate key warnings in the dev tools. Additionally, if someone has a simple solution to resolving the warnings, I'm all ears.
wbgh16ku4#
仍然在那里
35g0bw715#
仍然在那里👋