Skip to content

Commit ee5c664

Browse files
Teddy Bradfordsapegin
Teddy Bradford
authored andcommittedOct 3, 2018
Fix: Do not render an empty props table for TypeScript projects (#1158)
1 parent b6bbf80 commit ee5c664

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed
 

‎src/rsg-components/Pathline/PathlineRenderer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const styles = ({ space, fontFamily, fontSize, color }) => ({
1010
fontFamily: fontFamily.monospace,
1111
fontSize: fontSize.small,
1212
color: color.light,
13-
wordBreak: 'break-all'
13+
wordBreak: 'break-all',
1414
},
1515
copyButton: {
1616
marginLeft: space[0],

‎src/rsg-components/Usage/Usage.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import Props from 'rsg-components/Props';
44
import Methods from 'rsg-components/Methods';
5+
import isEmpty from 'lodash/isEmpty';
56

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

1011
if (!propsNode && !methodsNode) {
1112
return null;

‎src/rsg-components/slots/UsageTabButton.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import TabButton from 'rsg-components/TabButton';
4+
import isEmpty from 'lodash/isEmpty';
45

56
const UsageTabButton = props => {
67
const component = props.props;
7-
const showButton = component.props || (component.methods && component.methods.length > 0);
8+
const showButton = !isEmpty(component.props) || !isEmpty(component.methods);
89
return showButton ? <TabButton {...props}>Props & methods</TabButton> : null;
910
};
1011

0 commit comments

Comments
 (0)
Please sign in to comment.