小编foo*_*ird的帖子

使用孩子作为参数的故事书会引发错误“绑定模板不能用作组件”

根据 Storybook 的文档: https ://storybook.js.org/docs/react/workflows/stories-for-multiple-components

// List.stories.ts | List.stories.tsx

import React from 'react';

import { List, ListProps } from './List';

// Instead of importing ListItem, we import the stories
import { Unchecked } from './ListItem.stories';

const Template: Story<ListProps> = (args) => <List {...args} />;

export const OneItem = Template.bind({});
OneItem.args = {
  children: <Unchecked {...Unchecked.args} />,
};

Run Code Online (Sandbox Code Playgroud)

就像 React 元素一样,故事也可以用于儿童。

但是,我的代码遵循文档示例,但在下面抛出错误。

bound Template cannot be used as component.

我的代码:

// checkFormField.stories.tsx

import { Meta, Story } from '@storybook/react';
import CheckFormField …
Run Code Online (Sandbox Code Playgroud)

emotion reactjs next.js storybook

7
推荐指数
1
解决办法
6980
查看次数

标签 统计

emotion ×1

next.js ×1

reactjs ×1

storybook ×1