From 4522dd9c90ff833312e4be4d732984f4727debf9 Mon Sep 17 00:00:00 2001 From: Teddy Bradford Date: Wed, 3 Oct 2018 15:06:35 -0400 Subject: [PATCH] Fix: Do not render an empty props table for TypeScript projects (#1158) --- src/client/rsg-components/Usage/Usage.js | 5 +++-- src/client/rsg-components/slots/UsageTabButton.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/rsg-components/Usage/Usage.js b/src/client/rsg-components/Usage/Usage.js index 02641c92d..83448a4b3 100644 --- a/src/client/rsg-components/Usage/Usage.js +++ b/src/client/rsg-components/Usage/Usage.js @@ -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 && ; - const methodsNode = methods && methods.length > 0 && ; + const propsNode = !isEmpty(props) && ; + const methodsNode = !isEmpty(methods) && ; if (!propsNode && !methodsNode) { return null; diff --git a/src/client/rsg-components/slots/UsageTabButton.js b/src/client/rsg-components/slots/UsageTabButton.js index 98a33259f..227438a26 100644 --- a/src/client/rsg-components/slots/UsageTabButton.js +++ b/src/client/rsg-components/slots/UsageTabButton.js @@ -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 ? Props & methods : null; };