Skip to content

Commit

Permalink
Fix: Do not render an empty props table for TypeScript projects (#1158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy Bradford authored and Artem Sapegin committed Oct 8, 2018
1 parent 90082d5 commit 4522dd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/client/rsg-components/Usage/Usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import PropTypes from 'prop-types';
import Props from 'rsg-components/Props';
import Methods from 'rsg-components/Methods';
import isEmpty from 'lodash/isEmpty';

export default function Usage({ props: { props, methods } }) {
const propsNode = props && <Props props={props} />;
const methodsNode = methods && methods.length > 0 && <Methods methods={methods} />;
const propsNode = !isEmpty(props) && <Props props={props} />;
const methodsNode = !isEmpty(methods) && <Methods methods={methods} />;

if (!propsNode && !methodsNode) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/client/rsg-components/slots/UsageTabButton.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import TabButton from 'rsg-components/TabButton';
import isEmpty from 'lodash/isEmpty';

const UsageTabButton = props => {
const component = props.props;
const showButton = component.props || (component.methods && component.methods.length > 0);
const showButton = !isEmpty(component.props) || !isEmpty(component.methods);
return showButton ? <TabButton {...props}>Props & methods</TabButton> : null;
};

Expand Down

0 comments on commit 4522dd9

Please sign in to comment.