Skip to content

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.

@stevenpetryk stevenpetryk force-pushed the sub-component-support branch from 0bc4f8a to 611854c Compare January 28, 2022 03:15
@stevenpetryk stevenpetryk force-pushed the sub-component-support branch from 611854c to 52afa6f Compare January 28, 2022 03:15
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
Development

Successfully merging this pull request may close these issues.

Invalid JS generated under a certain TS export. Uses default reserved word Invalid JS generated under a certain TS export. uses default reserved word
2 participants