mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-17 05:02:23 +08:00
fix(official-storybook): use existing forward-ref story
This commit is contained in:
parent
1b7f55000e
commit
2c63dc63e7
@ -4,19 +4,25 @@ import { DocgenButton } from '../../components/DocgenButton';
|
||||
export default {
|
||||
title: 'Addons/Docs/ForwardRef',
|
||||
component: ForwardedButton,
|
||||
parameters: { chromatic: { disable: true } },
|
||||
parameters: {
|
||||
chromatic: { disable: true },
|
||||
docs: { source: { type: 'dynamic' } },
|
||||
},
|
||||
};
|
||||
|
||||
const ForwardedButton = React.forwardRef((props = { label: '' }, ref) => (
|
||||
<DocgenButton ref={ref} {...props} />
|
||||
));
|
||||
const ForwardedButton = React.forwardRef(function ForwardedButton(props = { label: '' }, ref) {
|
||||
return <DocgenButton ref={ref} {...props} />;
|
||||
});
|
||||
export const DisplaysCorrectly = () => <ForwardedButton label="hello" />;
|
||||
DisplaysCorrectly.storyName = 'Displays forwarded ref components correctly (default props)';
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
const ForwardedDestructuredButton = React.forwardRef(({ label = '', ...props }, ref) => (
|
||||
<DocgenButton ref={ref} label={label} {...props} />
|
||||
));
|
||||
const ForwardedDestructuredButton = React.forwardRef(function ForwardedDestructuredButton(
|
||||
// eslint-disable-next-line react/prop-types
|
||||
{ label = '', ...props },
|
||||
ref
|
||||
) {
|
||||
return <DocgenButton ref={ref} label={label} {...props} />;
|
||||
});
|
||||
export const AlsoDisplaysCorrectly = () => <ForwardedDestructuredButton label="hello" />;
|
||||
AlsoDisplaysCorrectly.storyName =
|
||||
'Displays forwarded ref components correctly (destructured props)';
|
||||
|
@ -4,7 +4,7 @@ import { DocgenButton } from '../../components/DocgenButton';
|
||||
const ButtonWithMemo = React.memo(DocgenButton);
|
||||
|
||||
export default {
|
||||
title: 'Addons/Docs/ButtonWithMemo',
|
||||
title: 'Addons/Docs/Memo',
|
||||
component: ButtonWithMemo,
|
||||
parameters: {
|
||||
chromatic: { disable: true },
|
Loading…
x
Reference in New Issue
Block a user