如何解决Storybook 6 全局装饰器不渲染组件
实现官方网站的示例装饰器后:
// .storybook/my-addon/register.js
import { makeDecorator } from '@storybook/addons';
export makeDecorator({
name: 'withSomething',parameterName: 'something',wrapper: (storyFn,context,{ parameters }) => {
// Do something with `parameters`,which are set via { something: ... }
// Note you may alter the story output if you like.
// Although generally that's not advised.
return storyFn(context);
}
})
// .storybook/preview.js
import React from 'react';
export const decorators = [(Story) => <div style={{ margin: '3em' }}><Story/></div>];
组件未呈现,我在控制台中收到此警告:
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
如果有人有解决方案,我将不胜感激。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。