目前,Styleguidist使用ReactExample来渲染组件。我想用我的自定义主题提供程序将所有ReactExample组件包装在一个页面中。正如您在下面看到的,所有的ReactExample组件都位于根Styleguide组件之外。
<StyleGuide />
<ReactExample />
<ReactExample />
<ReactExample />有没有办法配置或修改styleguidist来添加一个父组件来包装styleguidist的所有组件?
<ThemeProvider>
<StyleGuide />
<ReactExample />
<ReactExample />
<ReactExample />
</ThemeProvider>发布于 2020-09-23 14:30:36
您可以像这样包装所有组件:
在styleguide.config.js中
const path = require('path')
module.exports = {
styleguideComponents: {
Wrapper: path.join(__dirname, 'src/styleguide/Wrapper')
}
}components/Wrapper
import React, { Component } from 'react'
import { IntlProvider } from 'react-intl'
export default class Wrapper extends Component {
render() {
return (
<IntlProvider locale="en">{this.props.children}</IntlProvider>
)
}
}https://stackoverflow.com/questions/64018443
复制相似问题