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

Not working with forwardRef wrapped components #67

Closed
leepowelldev opened this issue Mar 27, 2019 · 7 comments
Closed

Not working with forwardRef wrapped components #67

leepowelldev opened this issue Mar 27, 2019 · 7 comments

Comments

@leepowelldev
Copy link

https://github.com/storybooks/babel-plugin-react-docgen/blob/fa170793df1d9065ba4bd25238627a72e55fbcb6/src/index.js#L49

This seems to exit early when a component is generated in a forwardRef call:

const Component = React.forwardRef(() => {
  return <div>Hello</div>
});

And as such does not attach any docgen data. This seems to stem from actualNameHandler.

@leepowelldev
Copy link
Author

leepowelldev commented Mar 27, 2019

Looks like v4 of react-docgen support this: reactjs/react-docgen#324, whether this would fix this issue I'm unsure as I think this plugin will still exit early.

@leepowelldev
Copy link
Author

Just tested this plugin using react-docgen@4 and can confirm a component wrapped in forwardRef works as expected if this is commented out:

if (!exportName) {
  // return;
}

So if we can fix actualNameHandler to recognise forwardRefs this should work.

@shilman
Copy link
Member

shilman commented Mar 27, 2019

any chance you can issue a PR for this? If so I can test and release an upgrade

@leepowelldev
Copy link
Author

Yes, I'm just working one up, will be with you shortly.

@leepowelldev
Copy link
Author

Added: #68

@danielduan
Copy link
Member

fixed in v3.0.0, will integrate into storybook.

@leepowelldev
Copy link
Author

Do you want me to create a PR to update to v3 here:
https://github.com/storybooks/storybook/blob/next/app/react/package.json

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

No branches or pull requests

3 participants