-
-
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
No props appearing for named function export with Addon-docs #9205
Comments
Are you using CRA? If so, have you tried the standalone preset? https://github.com/storybookjs/presets/tree/master/packages/preset-create-react-app Is |
Not using CRA, as this is a Components-only library (is bundled and then exported for use in a different project).
|
Try doing this, got out of the same problem.import React, { FC } from 'react';
import PropTypes from 'prop-types'
export interface DummyProps extends HTMLAttributes<HTMLElement> {
textProp:string;
};
export const Dummy: FC<DummyProps > = function ({ textProp }) {
return (
<div>
{ textProp }
</div>
);
};
Dummy.propTypes = {
/**
* Test code export
*/
textProp: PropTypes.string.isRequired,
};
export default Dummy; |
That seems a little excessive just to get Prop definitions working within Storybook - I was under the impression standard React could be used, rather than having to double up on type definitions for every Component. @shilman has there been any update on this? I've updated to 5.3.0-rc.9 and I'm still facing the same issue. |
@getignited Do you have a reproduction? |
@shilman I'll put something together for you. |
@shilman I've managed to reproduce that correctly here: https://github.com/getignited/storybook-docs-test |
@getignited
I need to jump onto something else, but maybe that gets you on the right path? |
@shilman I'll take a look at that, thank you. When I was setting that reproduction up, it definitely worked for a bit, until some of the Babel stuff started coming into play. Just got to figure out which one is upsetting it, I suppose! |
We've also run into this issue. Indeed Furthermore, it works with a dummy React component but doesn't work with Semantic UI React (SUIR) components... And all SUIR components do have a When a SUIR component reaches the This is on Storybook v5.3.3 and v5.3.6. Hope it helps with the debugging :-) |
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! |
@shilman I have the same problem with CRA
I have a component
In components, I'm using named exports and reexports if it matters |
I've noticed this same issue on a couple projects and was just able to track it down to the CRA preset. The props table works if I remove Here's my config setup: // main.js
var path = require('path');
module.exports = {
stories: ['../src/**/*.stories.mdx'],
addons: [
// '@storybook/preset-create-react-app',
'@storybook/addon-actions',
'@storybook/addon-storysource',
'@storybook/addon-knobs',
'@storybook/addon-a11y',
'@storybook/addon-docs',
],
webpackFinal: (config) => {
config.resolve.alias = {
'~': path.resolve(__dirname, '../src/'),
};
return config;
},
}; I also have a |
cc @mrmckeb |
@soulfresh, are you able to supply a simple repro repo? I can then take a look in context and see what's happening. We have this working with the preset in the |
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! |
Another one having the same issue here. It was working recently |
@Dashue do you have a repro? |
@shilman Hey Michael, thanks for your time. I've solved it by exporting one component to feed to the docs addon and another to consume and use in the story itself. I.e
Story:
|
@getignited Hey, Have you tried |
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! |
Hi all, i've a similar issue, and i didn't know how to fix it ? //main.js
|
We've overhauled props handling in 6.0, can somebody who's having this issue try upgrading and LMK if you're still having the issue? #9311 |
Hi @shilman , i've update to v6
But props it's steel not working and don't appear in docs tab. |
@Horsty80 do you have a public repro i can look at? |
Yes sure normally it's public, let me know if it's not here it's hosted test version of the repo |
Hi @shilman any news of this bug ? =/ |
Took me awhile to track down with @mrmckeb and I'm not very satisfied with where we got. Try adding the following to your const presets = ["@babel/preset-env", "@babel/preset-react"]; I modified a bunch of other things in the project in the process of debugging, but pretty sure that's the proper fix. WDYT? |
Thanks @shilman it's working fine ! So fix with :
|
@shilman after upgrading to with this const path = require('path');
interface TypescriptOptions {
check?: boolean;
docgen?: 'none' | 'react-docgen' | 'react-docgen-typescript';
}
export const typescript: TypescriptOptions = {
check: true,
docgen: 'react-docgen-typescript'
};
module.exports = {
typescript,
stories: ['../stories/**/*.story.@(js|jsx|ts|tsx)'],
addons: [
{
name: '@storybook/addon-docs',
options: {
sourceLoaderOptions: {
rule: {
include: [path.resolve(__dirname, '../stories')],
},
loaderOptions: {
prettierConfig: { printWidth: 80, singleQuote: false },
},
},
},
},
{
name: '@storybook/addon-storysource',
options: {
rule: {
include: [path.resolve(__dirname, '../stories')],
},
loaderOptions: {
prettierConfig: { printWidth: 80, singleQuote: false },
},
},
},
'@storybook/addon-knobs/register',
]
};
import React from 'react';
import { bootstrap } from "@ui/styleguide";
import { addDecorator ,addParameters} from '@storybook/react';
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';
import { StoryContainer } from "../stories/storyComponents/StoryContainer";
addDecorator(Story =>
<StoryContainer>
<Story />
</StoryContainer>
);
addParameters({
docs: {
container: DocsContainer,
page: DocsPage,
},
});
bootstrap(); Our example: import React from 'react';
import { ClickThing } from './ClickThing';
export default {
title: 'Components|Click',
component: ClickThing,
};
export const Basic = ({ value = 5, showZero = true }) => <ClickThing {...{ value, showZero }} />; import React, { FunctionComponent } from 'react';
export interface IClickProps {
value?: number;
maxDigits?: 1 | 2 | 3;
showZero?: boolean;
onClick?(value: number): void;
subject?: string;
}
export const ClickThing: FunctionComponent<IClickProps> = ({
value,
maxDigits,
showZero = false,
onClick = () => {},
children,
subject,
}) => (
<div>
{value}
<span>{showZero}</span>
<div>{subject}</div>
</div>
); |
@EdenTurgeman do you have a repro? |
@shilman |
@EdenTurgeman standalone minimal repro is the best way. if you have a bunch of issues around a specific feature, like prop tables, a repo that demonstrates all those issues in one place is also great |
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! |
Just popping in to say that I created a minimum repro for you, but everything was working fine, so … . In my own project, the props aren't showing up for a default export. If I change it to named (but won't, because code splitting) it works, and if I export it both ways (why is this allowed?), then I get props when I import it as a named component. At any rate, thanks for taking the time! Edit: Jeremy W. Sherman makes a point about using both. |
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! |
In my case is a Stencil component using the react integration. No propTypes on the component, but there are TypeScript
|
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! |
Same issue here. Proptypes are not shown not even in the example provided by Storybook: import React from 'react';
import PropTypes from 'prop-types';
import './button.css';
/**
* Primary UI component for user interaction
*/
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
return (
<button
type="button"
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
style={backgroundColor && { backgroundColor }}
{...props}
>
{label}
</button>
);
};
Button.propTypes = {
/**
* Is this the principal call to action on the page?
*/
primary: PropTypes.bool,
/**
* What background color to use
*/
backgroundColor: PropTypes.string,
/**
* How large should the button be?
*/
size: PropTypes.oneOf(['small', 'medium', 'large']),
/**
* Button contents
*/
label: PropTypes.string.isRequired,
/**
* Optional click handler
*/
onClick: PropTypes.func,
};
Button.defaultProps = {
backgroundColor: null,
primary: false,
size: 'medium',
onClick: undefined,
}; Versions:
|
Nevermind! Can confirm that adding and installing the following solved the issue for me:
|
On Storybook 6.1.21, I had the same issue as @keyserfaty, where it only showed a few props from the default "button" component that Storybook shipped with. The issue was because I completely overwrote the module.rules array in webackFinal function of main.js with my own webpack config. I instead spread storybooks rules first, then did my own webpack config: const webpackConfig = require('./../webpack.config');
module.exports = {
// ...
webpackFinal: async (config) => {
const appConfig = webpackConfig(); // my webpack config exports a function
return {
...config,
module: {
...config.module,
rules: [
...config.module.rules,
...appConfig.module.rules,
],
},
};
},
} |
Describe the bug
Been trying various things to get the props to appear for my component library with no luck. This is using the
5.3.0-rc.0
version of Storybook and Addon-docs.I've been trying with both
js
andmdx
file types and seeing no success. A named function export, with props and comments, renders in the Docs file with "No props found for this component".I've set up the MDX rules following the Manual configuration guide on the README.
Expected behavior
Props should be populated in Docs.
Code snippets
Component:
MDX:
Screenshots
System:
The text was updated successfully, but these errors were encountered: