ButtonGroup
コンポーネントレンダリングButton
を `react-styleguidist 'を使って記述したいと思います。反応スタイルガイドの依存関係を持つコンポーネントを追加するには
私はこのようになりますstyleguidistのWebPACKのコンフィグ持つ:src/components/
インサイド
module.exports = {
module: {
rules: [
{
test: /\.jsx?$/,
use: [
{
loader: 'babel-loader'
}
],
exclude: /node_modules/
}
]
},
devtool: 'cheap-module-eval-source-map'
}
I know that I dont need to define commonly used loaders and plugins because styleguidist already adds them internally
を、styleguidist
は私のコンポーネントをピックアップすることを可能にするためのディレクトリ構造が少し次のようになります。
Button
index.js
Readme.md
ButtonGroup
index.js
example.js (created for Case II after Case I failed)
Readme.md
ケースI
ディレクトリ内の私のReadme.md
で0
:
SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag (5:2)
ケースII
を私が囲んで試してみました:
```jsx
const Button = require('../index')
<ButtonGroup>
<Button type='primary' size='lg'>Hello, World</Button>
<Button type='primary' size='lg'>Hello, Doctor</Button>
</ButtonGroup>
```
私は、私のstyleguide
が言うエラーがあることを行います上記の図のようにButtonGroup
ディレクトリ内のexample.js
の情報、ファイルcon TAINS:
import React from 'react'
const ButtonGroup = require('./index')
const Button = require('../index')
export default function ButtonGroupExample (props) {
return (
<ButtonGroup>
<Button>Hello, World</Button>
<Button>Hello, Doctor</Button>
</ButtonGroup>
)
}
今の例コンポーネントはReadme.md
にインポートされる:
```jsx
const Example = require('./example')
(<Example />)
```
:
TypeError: require(...) is not a function
必要性を削除すると、スタイルガイド内のコンポーネントが互いに参照できるようになります。ありがとう、設定に関して、私は完全な制御モードを必要とするかもしれないストーリーブックとは異なり、ストーリーブックはそのようなオプションを提供しない – vamsiampolu