我的React组件是一个DynamicTable。我在组件中添加了一个简单的PropType,但是我也想在每个属性中添加一个描述。
这是我的propTypes:
public static String setSignificanDigits(double value, int significantDigits) {
if (significantDigits < 0) throw new IllegalArgumentException();
// this is more precise than simply doing "new BigDecimal(value);"
BigDecimal bd = new BigDecimal(value, MathContext.DECIMAL64);
bd = bd.round(new MathContext(significantDigits, RoundingMode.HALF_UP));
final int precision = bd.precision();
if (precision < significantDigits)
bd = bd.setScale(bd.scale() + (significantDigits-precision));
return bd.toPlainString();
}
如何将说明添加到故事书中?
答案 0 :(得分:0)
您似乎需要同时使用内联注释和react-docgen来填充此列。
Input.propTypes = {
...DefaultProps.Input,
/** text, which is shown until the text is written */
placeholder: PropTypes.string,
/** size of the input, ordinary by default, could be `md` */
size: PropTypes.oneOf([undefined, 'md']),
/** mask for masked input pattern */
mask: MaskedInput.propTypes.mask,
/** all the rest params (e.g. onClick) */
rest: PropTypes.any,
};
babel-plugin-react-docgen (add to .babelrc "plugins": ["react-docgen"])
参考文献:
https://github.com/storybookjs/storybook/issues/2010 https://github.com/storybookjs/storybook/issues/2708#issuecomment-454156949