-
-
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
Can't get props for addon-info when using decorator (higher order component) on my component #1735
Comments
Are those HOCs your own, or are they taken from some library like recompose? If the former, you may want to extend the output with static methods from input:
|
Unfortunately for me they are from libraries, in my case these are react-intl and material-ui (v1). |
@michalg42 There're two ways to get props in your case.
withInfo({
text: 'doc string about my component',
propTables: [Avatar],
})
If you're using Material-UI library you might try to use this Storybook addon: |
I'm getting an issue when manually specifying E: Have been doing some more investigation today and I don't think it's related to specifying |
@loliver I have the same issue with components that have linked a style sheet ( Maybe you have some thoughts how to resolve this? |
@loliver me too :( |
I wasn't able to find anything further, we've decided to stop using this addon for any documentation going forwards as it doesn't quite do what we need unfortunately. |
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 60 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! |
Here is a workaround I used in my project // ...
const Button = (props) => {
return (
<button}>Click me</button>
);
};
Button.propTypes = {
primary: PropTypes.bool,
secondary: PropTypes.bool,
};
export const ButtonComponent = Button;
export default withStyles(styles)(Button); And now my story will look like // ...
import Button, { ButtonComponent } from '../src/Button';
storiesOf('Button', module)
.add('Simple', withInfo({
text: 'Simple button description',
source: false,
propTables: [ButtonComponent], // display propTable for Button component
propTablesExclude: [Button], // do not display propTable for HOC
})(() => <Button primary>Primary Button</Button>)); |
Another solution is to add the propTypes after the HOC
|
I have tried @zhukmj and as I am using Flow, it just works partially and is not able to get all the information. |
I think this issue should still be opened, especially as CSSinJS becomes more popular |
Yeah I think the same, using
|
Hi everyone ! |
Props end up not being passed at all :/ |
@zhukmj's workaround works, but how can I get rid of the unnecessary HOC propTable? I see he is using |
1. Installed Storybook addons, and loaders in webpack.config.js 2. Uses react-docgen-typescript-loader to load propTable for the 'Info' addon 3. Renamed AppBar to NavBar so not to be confused with AppBar from Material-ui 4. Allow 'Info' addon to display propTypes of HOC-wrapped component *Resolution 1: - workaround suggested from storybookjs/storybook#1735. - export the original component before it was wrapped with MUI's withStyle() *Issue 2: - downside is 'classes' is undefined without withStyle(). Throws ts error in Storybook. *Resolution 2: - Added defaultProps object defined for 'classes'. This is unnecessary if we don't use Storybook's Info addon to display propTable 5. Created Stories for AppBar and Drawer
Hello
I wanted to use addon-info to get props in stories, but I got something like this in PropTypes section:
"withTheme(withStyles(Avatar))" Component
No propTypes defined!
Well, that's obvious for me why it's like this, but I would like to get props for Avatar, not its HOC. I couldn't find how to do it in readme, neither in issues.
How can I achieve this?
The text was updated successfully, but these errors were encountered: