mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-28 05:10:17 +08:00
Merge pull request #12164 from storybookjs/12138-html-fix-inline-rendering
Addon-docs: Fix inline rendering for DOM nodes in HTML
This commit is contained in:
commit
ff5f4804de
@ -4,9 +4,13 @@ import { StoryFn } from '@storybook/addons';
|
||||
export const parameters = {
|
||||
docs: {
|
||||
inlineStories: true,
|
||||
prepareForInline: (storyFn: StoryFn<string>) => (
|
||||
// eslint-disable-next-line react/no-danger
|
||||
<div dangerouslySetInnerHTML={{ __html: storyFn() }} />
|
||||
),
|
||||
prepareForInline: (storyFn: StoryFn<string>) => {
|
||||
const html = storyFn();
|
||||
if (typeof html === 'string') {
|
||||
// eslint-disable-next-line react/no-danger
|
||||
return <div dangerouslySetInnerHTML={{ __html: html }} />;
|
||||
}
|
||||
return <div ref={(node) => (node ? node.appendChild(html) : null)} />;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user