[Bug]: addon-doc does not show component description and proptypes #33198
Replies: 6 comments 1 reply
-
|
The difference is in how the components are exported. Storybook's docs extraction works reliably when you use an inline default export like To fix this, change your export to use the inline default export style: export default function Portal({ children, containerId = "wtw-portal-root" }) {
// ...
}This should make prop types and descriptions appear in Storybook docs for all your components. This pattern is the most robust for autodocs and prop extraction in Storybook 10 with React and Vite (example issue). To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
export default function Portal({ children, containerId = "wtw-portal-root" }) {
const [container, setContainer] = useState(null);
useEffect(() => {
let rafId = null;
const findContainer = () => {
const el = document.getElementById(containerId);
if (el) {
setContainer(el);
} else {
rafId = requestAnimationFrame(findContainer);
}
};
findContainer();
return () => {
if (rafId) cancelAnimationFrame(rafId);
};
}, [containerId]);
if (!container) return null;
return createPortal(children, container);
}
Portal.propTypes = {
/** React node rendered into the portal target. */
children: PropTypes.node.isRequired,
/** Target container id (string). Should match an existing element in the document (e.g., "wtw-navbar-search"). */
containerId: PropTypes.string,
};It does not work. |
Beta Was this translation helpful? Give feedback.
-
|
This does work: argTypes: {
containerId: {
control: "text",
description:
"DOM id of the target container where children are portaled.",
table: {
category: "Portal Props",
type: { summary: "string" },
defaultValue: { summary: '"wtw-portal-root"' },
},
},
children: {
description: "React node rendered into the portal target.",
table: {
category: "Portal Props",
type: { summary: "ReactNode" },
},
},
}, |
Beta Was this translation helpful? Give feedback.
-
|
Hey @SalahAdDin it seems that your component is not using any JSX. The |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
What about the following example @yannbf: import { useEffect } from "react";
import PropTypes from "prop-types";
import { initScrollGradient } from "./scrollGradient";
function ScrollGradientDemo({
startSelector,
startColorVar,
endColorVar,
threshold,
}) {
useEffect(() => {
const controller = initScrollGradient({
startSelector,
startColorVar,
endColorVar,
threshold,
});
return () => controller?.destroy?.();
}, [startSelector, startColorVar, endColorVar, threshold]);
return (
<div>
<section
style={{ height: "120vh", display: "grid", placeItems: "center" }}
id="first-section">
<h1 data-gradient-start>Scroll down</h1>
</section>
<section
style={{ height: "120vh", display: "grid", placeItems: "center" }}
id="second-section">
<p>Keep scrolling to see the background and theme change.</p>
</section>
<section
style={{ height: "120vh", display: "grid", placeItems: "center" }}
id="third-section">
<p>
Another section for keeping scrolling to see the background and theme
change.
</p>
</section>
</div>
);
}
ScrollGradientDemo.propTypes = {
/** CSS selector for the element where gradient progression starts. */
startSelector: PropTypes.string,
/** Starting color (hex) for the blended background. */
startColorVar: PropTypes.string,
/** Ending color (hex) for the blended background. */
endColorVar: PropTypes.string,
/** Scroll progress at which the end color is fully reached (0–1). */
threshold: PropTypes.number,
};
export default {
title: "Utilities/ScrollGradient",
component: ScrollGradientDemo,
parameters: {
layout: "fullscreen",
docs: {
description: {
component:
"Scroll-driven background gradient that blends between colors and updates theme variables.",
},
},
},
argTypes: {
startSelector: { control: "text" },
startColorVar: { control: "color" },
endColorVar: { control: "color" },
threshold: {
control: { type: "range", min: 0, max: 1, step: 0.01 },
},
},
};
export const Playground = {
args: {
startSelector: "[data-gradient-start]",
threshold: 0.6,
},
};Result:
|
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
It is something weird happening with out project: for some stories description and prop types are shown, but for other ones, they are not:
This works.
This does not work.
What is the difference?
Reproduction link
https://stackblitz.com/edit/github-tmyakrbd?file=src%2FPortal.stories.js
Reproduction steps
autodocsSystem
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions