When displaying Component information with @storybook/addon-info, we can see its accepted and default props. To define these, we would use Prop-Types. One of the available types is PropTypes.object. When used in a Component, @storybook/addon-info will not display it in the PropTypes table, we get empty DOM node (table cell) instead.
Other types render fine, just this one seems to get skipped.
Create a component like in the example below and render it with the addon.
@storybook/addon-info: 3.3.14@storybook/addons: 3.3.14@storybook/react: 3.3.14import React, { Component } from 'react';
import PropTypes from 'prop-types';
class ExampleComponent extends Component {
render() {
return <div>{this.props.children}</div>
}
}
ExampleComponent.propTypes = {
thisWillBeBlank: PropTypes.object,
};
export default ExampleComponent;
I can confirm this can be reproduced in official example:
http://storybooks-official.netlify.com/?selectedKind=Addons%7CInfo.React%20Docgen&selectedStory=Comments%20from%20PropType%20declarations&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Fstories%2Fstories-panel
BTW, is there any particular reason not to use propTypes.shape in your case?
Not really @Hypnosphi. And thank you!
This was brought up in a PR with other unrelated issues that I'm not sure is being merged here.
I found that the propType object is using the ObjectType component in src/components/types/PrettyPropType.js.
Inside src/components/types/ObjectType.js, we have:
const ObjectType = () => <span>{}</span>;
This is transpiled to:
var ObjectType = function ObjectType() {
return _react2.default.createElement('span', null);
};
Which renders an empty span.
Also, there is what I think is an orphan file, src/components/types/Object.js with the same contents as src/components/types/ObjectType.js.
@storybook/react 3.3.15
@storybook/addon-info 3.3.15
Please let me know if a PR to fix this issue would be accepted.
@CLL80 Good find! I hope @Hypnosphi says yes!
Please let me know if a PR to fix this issue would be accepted.
Sure, you're welcome
Released as 3.4.0-rc.4
Most helpful comment
This was brought up in a PR with other unrelated issues that I'm not sure is being merged here.
I found that the propType object is using the
ObjectTypecomponent insrc/components/types/PrettyPropType.js.Inside
src/components/types/ObjectType.js, we have:This is transpiled to:
Which renders an empty span.
Also, there is what I think is an orphan file,
src/components/types/Object.jswith the same contents assrc/components/types/ObjectType.js.Please let me know if a PR to fix this issue would be accepted.