如何解决如何使用自定义主题提供程序将所有react示例包装在styleguidist中?
当前,Styleguidist使用ReactExample渲染组件。我想用我的自定义主题提供程序将所有ReactExample组件包装在一个页面中。如下所示,所有ReactExample组件都位于根样式向导组件的外部。
<StyleGuide />
<ReactExample />
<ReactExample />
<ReactExample />
我是否可以配置或修改styleguidist来添加一个父组件,该组件将包装styleguidist的所有组件?
<ThemeProvider>
<StyleGuide />
<ReactExample />
<ReactExample />
<ReactExample />
</ThemeProvider>
解决方法
您可以像这样包装所有组件:
在 styleguide.config.js 中:
const path = require('path')
module.exports = {
styleguideComponents: {
Wrapper: path.join(__dirname,'src/styleguide/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>
)
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。