@storybook/react
v3.2.4@storybook/addon-info
v3.2.4官方示例中的这个条目
storiesOf('Button').addWithInfo(
'simple usage (custom propTables)',
`
This is the basic usage with the button with providing a label to show the text.
Since, the story source code is wrapped inside a div, info addon can't figure out propTypes on it's own.
So, we need to give relevant React component classes manually using \`propTypes\` option as shown below:
~~~js
storiesOf('Button')
.addWithInfo(
'simple usage (custom propTables)',
<info>,
<storyFn>,
{ inline: true, propTables: [Button]}
);
~~~
`,
() => (
<div>
<Button label="The Button" onClick={action('onClick')} />
<br />
</div>
),
{ inline: true, propTables: [Button] }
);
注意propTypes
用反引号括起来。
单词propTypes
以等宽字体与其所属的句子一起显示。
单词propTypes
变成了一个空的<pre><code></code></pre>
元素,如下所示。
<Code>
,它在<pre>
实现为<code>
<pre>
,这是一个将句子分成两部分的块元素。<Code>
呈现来自this.props.code
的文本,但实际文本在this.props.children
。@MrOrz我也遇到了这个问题,并将在此 PR #1501 中修复它
谢谢您的帮助!
听到这真是太好了!
我可以覆盖marksyConf
来解决这个问题,所以不要急于公关,慢慢来;)
前任:
import React from 'react';
import { configure } from '@storybook/react';
import { setDefaults } from '@storybook/addon-info';
function Code({ children }) {
return <code>{children}</code>;
}
function loadStories() {/* loading stories here */}
setDefaults({ marksyConf: { code: Code } });
configure(loadStories, module);
看起来code
用于内联和块代码部分。
对于内联代码,它应该呈现props.children
但对于代码块props.code
最有用的评论
看起来
code
用于内联和块代码部分。对于内联代码,它应该呈现
props.children
但对于代码块props.code