如何将组件导出到故事书

时间:2020-07-09 08:24:45

标签: reactjs storybook

我正在练习故事书,这是我的代码 # Setup the pipeline with the required steps: steps steps = [('scaler', StandardScaler()), ('imputation', SimpleImputer(missing_values=np.NaN, strategy='most_frequent')), ('svc', SVC(max_iter = 9000, kernel='linear',probability=True))] # Create the pipeline: pipeline pipeline = Pipeline(steps) #Define hyperparameters and range of Grid Search parameters = {"svm__C": np.logspace(-5, 8, 15), "svm__gamma": [0.00001, 0.0001, 0.001, 0.01, 0.1]}

src/component/Table.js

这是我的故事书代码 import React, {Component} from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import Table from './components/Table' class Table extends Component { render() { return ( <table class="table table-hover"> <thead> <tr> <th>ID</th> <th>NAME</th> <th>PRICE</th> <th>OPTION</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> ); } } export default Table;

src/stories/Button.story.js

我想通过import React from 'react'; import { action } from '@storybook/addon-actions'; import { Button } from '@storybook/react/demo'; import 'bootstrap/dist/css/bootstrap.css'; import {Table} from './components/Table'; export default { title: 'Button', component: Button, }; export default {Table}; Table文件夹中导出components,但是我不知道如何导出它,有人可以帮助我吗?拜托,非常感谢

当我这样导出时,它显示错误:storybook

1 个答案:

答案 0 :(得分:1)

我认为可能会出现此问题,因为您的代码中有两个默认导出。

您可以尝试这样的事情吗

import React from 'react';
import {Table} from './components/Table';

export default {
  component: Table,
  title: 'Table',
};

export const sample = () => <Table />;