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

Support sub-components assigned to default export #411

Merged
merged 1 commit into from
Mar 15, 2022

Conversation

stevenpetryk
Copy link
Contributor

@stevenpetryk stevenpetryk commented Jan 28, 2022

This prevents an issue where, when a component is the default export of a file, assigning any other component as a property causes the docgen to put default in the component's display name.

This fixes #394 and upstream would fix hipstersmoothie/react-docgen-typescript-plugin#57. It's a somewhat naive fix, but it keeps the test suite passing.

export default function Root(props: { name: string }) {
return <span>root {props.name}</span>;
}
Root.displayName = 'Root';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to explicitly set displayName here because, if I don't, the docgen incorrectly names this component SubComponent (naming it after the file). I feel like it's tangentially related to #395.

description: ''
}
},
Sub: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the change below, the component names are Root and default.Sub, which is not correct.

@stevenpetryk stevenpetryk marked this pull request as ready for review January 28, 2022 03:18
@pvasek pvasek merged commit 358bc9b into styleguidist:master Mar 15, 2022
pvasek pushed a commit to pvasek/react-docgen-typescript that referenced this pull request Mar 15, 2022
pvasek added a commit that referenced this pull request Mar 15, 2022
fix: the merging of PR #411 introduced a regression error
abharvey pushed a commit to abharvey/react-docgen-typescript that referenced this pull request Jun 14, 2022
fix: the merging of PR styleguidist#411 introduced a regression error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants