【发布时间】:2021-11-06 22:40:24
【问题描述】:
我指定了接口:
interface Props{
type: 'dog' | 'cat' | 'mouse' | 'turtle' | 'rabbit'
}
export default Props;
实际上,所有允许的string 值的列表很长。是否可以根据Props 在Storybook 中填充我的故事?
我试过这样做:
import React, {ReactElement} from 'react';
import Props from '../typings';
export default {
title: 'Animals',
component: Animal,
argTypes: {
type: {
control: {
type: 'select',
options: [...Props.type],
},
},
},
};
【问题讨论】:
-
恐怕你不能。接口和类型只能在类型赋值中,不能在非类型中。
标签: reactjs typescript storybook