addon-docs: "No props found for this component" when component is exported in camelCase
See original GitHub issueDescribe the bug
Props table is empty when the default exported variable of the component file was in the camel case format.
Code snippets
Here is my MDX file:
icon-button.stories.mdx
import { Meta, Props } from '@storybook/addon-docs/blocks';
import IconButton from './icon-button';
<Meta
component={IconButton}
title="IconButton"
/>
## Props
<Props of={IconButton} />
And here is my component:
Not working when the default exported variable is “iconButton”
icon-button.tsx
import PropTypes from 'prop-types';
import React, { FC } from 'react';
import './icon-button.scss';
export interface IProps {
/**
* button color
*/
color?: string;
}
const iconButton: FC<IProps> = function IconButton(props) {
return <div className="icon-button">icon-button</div>;
};
iconButton.propTypes = {
color: PropTypes.string,
};
iconButton.defaultProps = {
color: 'primary',
};
export default iconButton;
Not it works after I changed the default exported variable to “iconbutton”
icon-button.tsx
import PropTypes from 'prop-types';
import React, { FC } from 'react';
import './icon-button.scss';
export interface IProps {
/**
* button color
*/
color?: string;
}
const iconbutton: FC<IProps> = function IconButton(props) {
return <div className="icon-button">icon-button</div>;
};
iconbutton.propTypes = {
color: PropTypes.string,
};
iconbutton.defaultProps = {
color: 'primary',
};
export default iconbutton;
Screenshots
Expected behavior Should still work with camelCase
System:
System: OS: macOS Mojave 10.14.4 CPU: (4) x64 Intel® Core™ i7-4578U CPU @ 3.00GHz Binaries: Node: 10.16.3 - /usr/local/bin/node Yarn: 1.21.1 - ~/.yarn/bin/yarn npm: 6.13.4 - /usr/local/bin/npm Browsers: Chrome: 79.0.3945.130 Firefox: 70.0.1 Safari: 12.1 npmPackages: @storybook/addon-a11y: ^5.3.7 => 5.3.7 @storybook/addon-actions: ^5.3.7 => 5.3.7 @storybook/addon-docs: ^5.3.7 => 5.3.7 @storybook/addon-jest: ^5.3.7 => 5.3.7 @storybook/addon-knobs: ^5.3.7 => 5.3.7 @storybook/addons: ^5.3.7 => 5.3.7 @storybook/core: ^5.3.7 => 5.3.7 @storybook/react: ^5.3.7 => 5.3.7
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (4 by maintainers)
Top GitHub Comments
OP could you try changing your code to use
import * as React from 'react';
?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!