-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Description and Props slots not shown when using TS and Component.displayName #9493
Comments
I poked around in the code base and found line 34 in storybook/addons/docs/src/blocks/utils.ts Lines 23 to 39 in 66c524f
|
@patricklafrance mind taking a look? |
@eriktoyra - i think the displayName is used by |
@atanasster Thank's for looking that up! It seems you are correct. But the purpose of Given the fact that this bug does not occur when using |
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! |
OP could you try changing your code to use |
@sidhuko Tried that just now. It had no effect unfortunately. Even tried to update Storybook to 5.3.13 (latest as of now) but still no effect. |
@eriktoyra can you try disabling |
@shilman It had no effect I'm afraid. Or maybe I dit it the wrong way? Did the following:
Let me know if I can assist in some other way with this issue. |
@eriktoyra one more thing 😄 Try changing: export const EmpireAlert: React.FC<EmpireAlertProps> = ({
title = "Code Yellow",
message
}) => ( To: export const EmpireAlert: React.FC<EmpireAlertProps> = ({
title = "Code Yellow",
message
}: EmpireAlertProps) => ( Workaround for reactjs/react-docgen#387 |
@shilman Still no success. The only way I can make it work is as in my code comment below. It seems very much related to the
I'm still having a theory that using a |
Looks like the issue specifically has to do with the filename of the component. For example if I do This one fails to find props: /***/ "./src/molecules/quote/product-section-header/product-section-header.tsx":
/*!*******************************************************************************!*\
!*** ./src/molecules/quote/product-section-header/product-section-header.tsx ***!
\*******************************************************************************/
/*component implementation removed*/
try {
// @ts-ignore
productsectionheader.displayName = "productsectionheader";
// @ts-ignore
productsectionheader.__docgenInfo = { /* data removed */ };
// @ts-ignore
if (typeof STORYBOOK_REACT_CLASSES !== "undefined")
// @ts-ignore
STORYBOOK_REACT_CLASSES["src/molecules/quote/product-section-header/product-section-header.tsx#productsectionheader"] = { docgenInfo: productsectionheader.__docgenInfo, name: "productsectionheader", path: "src/molecules/quote/product-section-header/product-section-header.tsx#productsectionheader" };
}
catch (__react_docgen_typescript_loader_error) { }
/***/ }), vs. if I name the file /***/ "./src/molecules/quote/product-section-header/ProductSectionHeader.tsx":
/*!*****************************************************************************!*\
!*** ./src/molecules/quote/product-section-header/ProductSectionHeader.tsx ***!
\*****************************************************************************/
/*component implementation removed*/
exports.ProductSectionHeader = ProductSectionHeader;
try {
// @ts-ignore
ProductSectionHeader.displayName = "ProductSectionHeader";
// @ts-ignore
ProductSectionHeader.__docgenInfo = { /* data removed */};
// @ts-ignore
if (typeof STORYBOOK_REACT_CLASSES !== "undefined")
// @ts-ignore
STORYBOOK_REACT_CLASSES["src/molecules/quote/product-section-header/ProductSectionHeader.tsx#ProductSectionHeader"] = { docgenInfo: ProductSectionHeader.__docgenInfo, name: "ProductSectionHeader", path: "src/molecules/quote/product-section-header/ProductSectionHeader.tsx#ProductSectionHeader" };
}
catch (__react_docgen_typescript_loader_error) { }
/***/ }), In my scenario I am just using |
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! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
I ran into this issue just a bit ago as well. We wanted to preface our components with the library name for better specificity in React DevTools. Have not had any luck with any of the workaround or suggestions above. |
Facing same issue |
+1 still having this issue. Svelte + TS |
@phocks I just tried it, and I couldn't reproduce it with the latest Storybook version. Can you provide a reproduction with the latest version of Storybook? |
Describe the bug
@storybook/addon-docs fails to populate the "Description" and "Props" slots in the following scenario;
Component.displayName
and the display name is assigned a string that doesn't match the component's name exactly.To Reproduce
Here's a sample repo which reproduces this bug: https://github.com/eriktoyra/storybook-component-displayname-bug
npm run storybook
EmpireAlert
story in the storybook and go to the Docs tab. Note that both the "Description" and "Props" slots are populated../src/components/EmpireAlert.tsx
and uncomment//EmpireAlert.displayName = "RebelAlliance.EmpireAlert"
on line 47. (You might have to restart Storybook to see the effect)Expected behavior
I expect
Component.displayName
to have no effect at all on "Description" and "Props" in the docs. ThedisplayName
string is meant for debugging purposes.Screenshots
Actual result
Expected result
Code snippets
./.storybook/main.js
./src/components/EmpireAlert.tsx
./src/components/EmpireAlert.stories.tsx
System:
Storybook 5.3.3 is also affected.
Additional context
Yes, I will be able to assist in pushing a PR for this given som guidance.
The text was updated successfully, but these errors were encountered: