mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-17 05:02:23 +08:00
fix(official-storybook): fix displayName for memo & add forward-ref example
Component should be fed directly to React.memo|forwardRef functions so that displayName is set. Previously was passing an anonymous arrow fn...
This commit is contained in:
parent
f80bc26810
commit
1b7f55000e
@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
import { DocgenButton } from '../../components/DocgenButton';
|
||||
|
||||
const ButtonWithForwardRef = React.forwardRef(DocgenButton);
|
||||
|
||||
export default {
|
||||
title: 'Addons/Docs/ButtonWithForwardRef',
|
||||
component: ButtonWithForwardRef,
|
||||
parameters: {
|
||||
chromatic: { disable: true },
|
||||
docs: { source: { type: 'dynamic' } },
|
||||
},
|
||||
};
|
||||
|
||||
export const displaysCorrectly = () => <ButtonWithForwardRef label="Hello forwardRef World" />;
|
||||
displaysCorrectly.storyName = 'Displays components with forwardRef correctly';
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { DocgenButton } from '../../components/DocgenButton';
|
||||
|
||||
const ButtonWithMemo = React.memo((props) => <DocgenButton {...props} />);
|
||||
const ButtonWithMemo = React.memo(DocgenButton);
|
||||
|
||||
export default {
|
||||
title: 'Addons/Docs/ButtonWithMemo',
|
||||
@ -12,5 +12,5 @@ export default {
|
||||
},
|
||||
};
|
||||
|
||||
export const displaysCorrectly = () => <ButtonWithMemo label="Hello World" />;
|
||||
export const displaysCorrectly = () => <ButtonWithMemo label="Hello memo World" />;
|
||||
displaysCorrectly.storyName = 'Displays components with memo correctly';
|
||||
|
Loading…
x
Reference in New Issue
Block a user