Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Addon-docs] ForwardRef has props === undefined during exractProps #8894

Closed
shmidt-i opened this issue Nov 20, 2019 · 4 comments · Fixed by #12686
Closed

[Addon-docs] ForwardRef has props === undefined during exractProps #8894

shmidt-i opened this issue Nov 20, 2019 · 4 comments · Fixed by #12686

Comments

@shmidt-i
Copy link

Describe the bug
ForwardRef components receive undefined as props during exractProps step.
https://github.com/storybookjs/storybook/blob/next/addons/docs/src/frameworks/react/extractProps.ts#L28-L31

Check out code snippets [1], [2]

Both are actually incorrect, since in React runtime you always have the props object presented, it just doesn't have any keys on it if no props were passed.

To Reproduce
If you change examples/official-storybook/components/ForwardedRefButton.js to have a destructuring on props, the props extraction process will fail, e.g. [3]

And then check the story examples/official-storybook/stories/addon-docs/props.stories.mdx.
There would be no props available for the component.

Expected behavior
Props table is shown

Code snippets
[1]:

processedComponent = component.render().type;

[2]:

processedComponent = component.type().type;

[3]:

const ForwardedRefButton = forwardRef(({ disabled, ...restProps }, ref) => (
  <BaseButton disabled={disabled} {...restProps} forwardedRef={ref} />
));

System:
Replicated in latest storybook repo's examples, but originally found in @storybook/addon-docs@5.2.5.

Additional context
Here is a downgrade commit in our repo that fixed the behaviour: nordnet/ui@6cf7ee5.

The component that failed was https://github.com/nordnet/ui/tree/master/src/Atoms/Box

@stale
Copy link

stale bot commented Dec 11, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Dec 11, 2019
@shilman shilman added the todo label Dec 11, 2019
@stale stale bot removed the inactive label Dec 11, 2019
shilman added a commit that referenced this issue Feb 14, 2020
@shilman
Copy link
Member

shilman commented Feb 14, 2020

Repro: 822f3df

@shilman
Copy link
Member

shilman commented Oct 5, 2020

@andezzat here's the forwardRef case as we discussed relative to #12638

@shilman
Copy link
Member

shilman commented Oct 8, 2020

Jeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.21 containing PR #12686 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants